I'm attempting to move a Local Script from ServerScriptService to a player once they join but keep running into road blocks. Someone tried to help me out by giving me this script :
game.Players.PlayerAdded : connect (function(player) ls = game.ServerScriptService.LocalScript : clone () ls.Parent = Player.Character end)
When I found that the above script didn't work, I attempted to fix it on my own:
game.Players.PlayerAdded : connect (function(player) player = game.ServerScriptStorage.LocalScript : clone () player.Parent = game.Players.LocalPlayer.Character end)
Well, the ServerScriptService is meant mainly to be used as a backup to the Workspace as a storage for scripts. You know how you might always see Scripts in the Workspace? Just move them to the ServerScriptService and they'll work from there. But, as a Local Script, it might not function as well. Instead, you can move it to ServerStorage, or ReplicatedStorage if you are planning to use it from GUIs and things.
local Storage = game:GetService("ServerStorage") -- Just a storage, you do not need to add this. local Script = Storage:WaitForChild("LocalScript") -- To refer to the Script more easily instead of looking for this one script named LocalScript every time a player joins. game.Players.PlayerAdded:connect(function(Player) -- When the player joins... wait() -- We wait because the Character might actually not exist yet... local Character = Player.Character -- Before we check for the Character.... Script:clone().Parent = Character -- And give it a clone of the script. end)