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

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

Asked by 7 years ago

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 :/

0
".Parent.WeldHandler" do you mean script.Parent.WeldHandler? User#5423 17 — 7y
0
Check your output lol. This errors on line 2. RubenKan 3615 — 7y
0
Well it's written correctly ;-; but somehow the 'script' was removed when I copied my code, so that's not the problem VladimVladim 78 — 7y

1 answer

Log in to vote
0
Answered by
Master_JJ 229 Moderation Voter
7 years ago

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.

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 VladimVladim 78 — 7y
Ad

Answer this question