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

This works in Studio, but not ingame?

script.Parent.MouseButton1Down:connect(function(Click)
	local player = game.Players.LocalPlayer
	player:LoadCharacter()
end)

4 answers

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

2 comments

1

I used a LocalScript.

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.

game.Players.PlayerAdded:connect(function(nP)
script.Parent.MouseButton1Down:connect(function(Click)
    local player = nP
    player:LoadCharacter()
end)
end)

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

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