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

This works in Studio, but not ingame?

Asked by 10 years ago
script.Parent.MouseButton1Down:connect(function(Click)
    local player = game.Players.LocalPlayer
    player:LoadCharacter()
end)

4 answers

Log in to vote
3
Answered by 10 years ago

The LocalPlayer property can only be used in LocalScripts.

Ad
Log in to vote
1
Answered by
Sublimus 992 Moderation Voter
10 years ago

Scripts that access 'LocalPlayer' must be used in LocalScripts within a Local directory, such as the PlayerGui.

1
I used a LocalScript. mario6325 55 — 10y
0
Okay, so loadcharacter can only be used in regular scripts, so you will have to use a regular script and access the player a different way. Sublimus 992 — 10y
Log in to vote
0
Answered by 10 years ago
game.Players.PlayerAdded:connect(function(nP)
script.Parent.MouseButton1Down:connect(function(Click)
    local player = nP
    player:LoadCharacter()
end)
end)
Log in to vote
0
Answered by 10 years ago

The Term ' LocalPlayer ' can only be used in a local script

Answer this question