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

How do I make a localscript be removed and cloned again into the character?

Asked by 5 years ago

I want to be able to click a button to make a local script in an object in the character be removed and then another local script will be cloned into the object. Here is the script:

local re = game.ReplicatedStorage.GlowbandRed

re.OnServerEvent:Connect(function(player)
    local player = game.Players.LocalPlayer
    local character = player.Character
    character.Bracelet.LocalScript:Destroy()
    wait(0.1)
    character.Bracelet2.LocalScript:Destroy()
    wait(0.1)
    local glowbandred = game.ServerStorage.GlowbandRed
    glowbandred:Clone()
    glowbandred.Parent = character.Bracelet
    wait(0.1)
    local glowbandred2 = game.ServerStorage.GlowbandRed2
    glowbandred2:Clone()
    glowbandred2.Parent = character.Bracelet2
end)

Of course, for an FE game.

0
Line 4 would error. LocalPlayer is nil on the server. User#19524 175 — 5y
0
I tried more options and using LocalPlayer and they didn't work, any ways to find the character? Asynchronize 16 — 5y
0
Why don't you pass on the player from the local script that fires the remote? Delude_d 112 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

remove line 4, player is already defined by the remote for character you can use

character = workspace:FindFirstChild(player.Name)
Ad

Answer this question