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

Why can't I clone a LocalScript into player that just joined?

I want to place a LocalScript into player when that player joins, so the LocalScript would always work in him. I used these lines.

local Players = game:GetService('Players')
local WeldHandler = .Parent.WeldHandler

Players.PlayerAdded:connect(function(player)
	local clonedscript = WeldHandler:Clone()
	clonedscript.Parent = player
end)

And that isn't appearing when I test the game :/

3 comments

0

".Parent.WeldHandler" do you mean script.Parent.WeldHandler?

0

Check your output lol. This errors on line 2.

0

Well it's written correctly ;-; but somehow the 'script' was removed when I copied my code, so that's not the problem

1 answer

The first error I found was on line 2, you put local WeldHandler = .Parent.WeldHandler, I think you meant to put local WeldHandler = script.Parent.WeldHandler.

Second thing that I would change is on line 6, you put the cloned script into the player, if I were you I would place it in the player.PlayerScripts, which was made to hold local scripts in the player.

1 comment

0

Well line 2 is not a problem as it is because of this site and not of that I can't write :P and I already solved my problem with another way

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