Table not being passed in RemoteEvent

I’m trying to pass a table through a remoteevent, and the first time I do it in the same script it works but afterwards it doesn’t.
Script part that works:

gui.AiInfo.Spawn.MouseButton1Click:Connect(function()
    for i, v in pairs(gui.AiInfo.SpawnsList:GetChildren()) do
        if v:IsA("TextButton") then
            v:Destroy()
        end
    end
    for i, v in pairs(rep.EnemyStuff:GetChildren()) do
        if v:IsA("Model") and v:FindFirstChild("Humanoid") then
            local newbutton = Instance.new("TextButton", gui.AiInfo.SpawnsList)
            newbutton.Name = v.Name
            newbutton.Text = v.Name
            newbutton.TextScaled = true
            newbutton.BorderSizePixel = 2
            newbutton.BackgroundColor3 = Color3.fromRGB(130, 123, 73)
            newbutton.MouseButton1Click:Connect(function()
                **comm:FireServer({reason = "spawnhere", name = v.Name})**
            end)
        end
    end
    gui.AiInfo.SpawnsList.Visible = not gui.AiInfo.SpawnsList.Visible
end)

Script part that doesn’t work:

gui.AiInfo.Background.Freeze.MouseButton1Click:Connect(function()
**comm:FireServer({reason = "updateai", change = "freeze"})**
end)

Can you also give the server side of the code?

1 Like
comm.OnServerEvent:Connect(function(plr, mobargs)
    
    if plr:GetRankInGroup(32732499) >= 252 then
        print(mobargs)
        if mobargs.reason == "spawnhere" then
            local spawnmob = rep.EnemyStuff[mobargs.name]:Clone()
            spawnmob.Name = mobargs.name
            spawnmob.Parent = spawned
            local mobdata = {
                
                health = {
                    maxhp = spawnmob.Humanoid.MaxHealth,
                    hp = spawnmob.Humanoid.Health
                },
                name = spawnmob.Name,
                state = "Frozen"
            }
            local newai = AIMeta.new(spawnmob.Humanoid.aitype.Value, spawnmob, mobdata)
            AIInstances[spawnmob.Name] = newai
            updateabilities()
            spawnmob:PivotTo(plr.Character:WaitForChild("HumanoidRootPart").CFrame)
        end
        if mobargs.reason == "updateai" then
        local mobtarget = plr.PlayerGui.DebugPanel.AiInfo.Target.Value
            if AIMeta:FindAiFromObject(mobargs.target) ~= false then
                local ai2 = AIMeta:FindAiFromObject(mobtarget)
            
                if mobargs.change == "freeze" then
                    if ai2.state == "Frozen" then
                        ai2.abilities.Idling.action(mobtarget)
                    else
                        ai2.abilities.Frozen.action(mobtarget)
                    end
                end
                
            end
        end
        if mobargs.reason == "fetch" then
            
            
            
        end
        
        
    end
    
end)```
1 Like

So printing the mobargs doesn’t work the second time?

The print works the first time, but not the second time, also the print works every time i use the spawn function, but no matter what i pass through on the freeze function it wont find a table

Nevermind, I’ve fixed the error now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.