Sleitnick / Knit

Lightweight game framework for Roblox
https://sleitnick.github.io/Knit/
MIT License
568 stars 97 forks source link

Untraceable Error when adding a certain line #243

Closed shaunkaddin closed 4 months ago

shaunkaddin commented 7 months ago

When adding a local character = Knit.GetService("CharacterService"):GetCharacter(game.Players.LocalPlayer) to a controller on the client it makes a untraceable error and the only solution is to have services return promises which I am avoiding doing this was also happening with adding Players:GetUserThumbnailAsync(suspect.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420) to my controller as well.

image

Sleitnick commented 7 months ago

Hello, thanks for the report. Can you share more code to reproduce this issue? This error usually occurs when you try to explicitly resume a thread with functions like coroutine.resume and task.spawn.

shaunkaddin commented 7 months ago

`
local Players = game:GetService("Players") local TweenService = game:GetService("TweenService") local Replicated = game:GetService("ReplicatedStorage")

local Player = Players.LocalPlayer
local Modules = Replicated.Knit.Modules
local Interfaces = Replicated.Knit.Objects.Interfaces

local MDTData = require(Modules.MDTData)
local date = require(Replicated.Knit.Modules.Date)
local Knit = require(Replicated.Knit.Packages.Knit)

local chargeFrame = Replicated.Knit.Objects.Interfaces.ChargeFrame

local Booking = {
    Name = "Booking"
}

function Booking:Show(suspect: Player)
    local Interface = Player.PlayerGui.Interface.Booking
    local Booking = Interface.Booking
    local Suspect = Booking.Suspect
    local Date = Booking.Date

    Suspect.ID.Text = "ID: {suspect.UserId}"

    -- TODO:Gang

    Date.Date.Text = date("%m/%d/%y")
    Date.Time.Text = date("%I:%M:%S")
end

function Booking:Hide() end

function Booking:AddCharge(name,charge)

end

function Booking:Init()
    local Interface = Player.PlayerGui.Interface.Booking
    local Booking = Interface.Booking
    local Charges = Interface.Charges

    local BookingService = Knit.GetService("BookingService")
    local CharacterService = Knit.GetService("CharacterService")

    self.Interface = Interface
    self.BookingService = BookingService
    self.CharacterService = CharacterService

    -- ERRORS HERE
    local character = Knit.GetService("CharacterService"):GetCharacter(game.Players.LocalPlayer)
    print(character)

    Booking.TopFrame.GroupRole.Text = "{Player:GetRoleInGroup(6071049)} ({Player:GetRoleInGroup(6070960)})"
    Booking.TopFrame.Top.Text = "Welcome, {Player:GetRoleInGroup(6071049)} {Player.Name}"
    Charges.Top.GroupRole.Text = "{Player:GetRoleInGroup(6071049)} ({Player:GetRoleInGroup(6070960)})"
    Charges.Top.Top.Text = "Welcome, {Player:GetRoleInGroup(6071049)} {Player.Name}"

    for name, charge in next, MDTData.Charges do
        local Clone = chargeFrame:Clone()
        Clone.Name = name
        Clone.Charge.Text = name
        Clone.Time.Text = charge.Time
        Clone.Parent = Charges.Frame

        Clone.Button.MouseButton1Click:Connect(function()
            self:AddCharge(name,charge)
        end)
    end

    Booking.Charges.MouseButton1Click:Connect(function()
        Charges.Visible = true
        Booking.Visible = false
    end)

    Booking.Cancel.MouseButton1Click:Connect(function()
        Charges.Visible = false
        Booking.Visible = false
    end)

    Charges.Search:GetPropertyChangedSignal("Text"):Connect(function()
        local closest = nil

        for _, charge in next, Charges.Frame:GetChildren() do
            if not charge:IsA("Frame") then
                continue
            end

            local start, stop = string.find(charge.Name:lower(), Charges.Search.Text:lower(), 1, true)

            if start == nil then
                charge.Visible = false
            else
                charge.Visible = true
            end
        end
    end)

    --self:Show(game.Players.LocalPlayer)

    return Booking
end

return Booking`

This is the modulecript that is that is having this problem, its just a simple script thats called from a controller that handles my UI elements with :Init() I do not believe I usecoroutine.resumeortask.spawn` in any of my scripts from right now.

r0b3rtb03 commented 7 months ago

Please respond Mr.Owner , Sleitnick.

howmanysmall commented 7 months ago

he's likely busy, don't do that

this error is likely isn't breaking things, it just kind of happens

where is the :Init code being called from in your controller?

Sleitnick commented 4 months ago

248