Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

3 comments

0

Line 4 would error. LocalPlayer is nil on the server.

0

I tried more options and using LocalPlayer and they didn't work, any ways to find the character?

0

Why don't you pass on the player from the local script that fires the remote?

1 answer

✓ Accepted answer

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

character = workspace:FindFirstChild(player.Name)

This discussion is preserved as it was. New answers, comments, and votes are closed.