Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix problem with ChildAdded in LocalScript?

Asked by
Diltz_3 75
5 years ago

Hello, everyone. I wanted to make Hand To monitor. And I have problem. ChildAdded is not work I don't know why. I'm not getting Error.

Code: (LocalScript)

local Player = game:GetService("Players").LocalPlayer

game:GetService("Players").ChildAdded:connect(function(child)
    local Button = Instance.new("TextButton",script.Parent.Main)
    Button.Text = child.Name
    Button.Name = child.Name
    Button.TextScaled = true

    Button.MouseButton1Click:connect(function()
        if Player.Character:FindFirstChildOfClass("Tool") then
            local Tool = Player.Character:FindFirstChildOfClass("Tool")
            local GetClone = Tool:Clone()
            GetClone.Parent = game:GetService("Players"):FindFirstChild(Button.Text).Backpack
        end
    end)
end)
0
You should use PlayerAdded, not ChildAdded. Also, you shouldn’t be using PlayerAdded from a localscript. User#19524 175 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Your script is not working because a localscript can't do anything to other clients. Localscripts only work for their client. To fix this problem, I would use a server script instead.

Don't know what else to add, really. Ask if you have questions.

0
u are beautiful Elixcore 1337 — 5y
Ad

Answer this question