So I need ways of getting LocalPlayer in a cloned Server-Side Script. I originally intended on using
game.Players.PlayerAdded:connect(function(player)
but because it's cloned, PlayerAdded doesnt seem to function correctly. Any other ways of getting the LocalPlayer on a server-side script?
For context, and if it helps:
game.Players.PlayerAdded:connect(function(player) script.Parent.Touched:connect(function(hit) if hit.Parent.Name == "Pickaxe" then player.Backpack.Copper.Value = player.Backpack.Copper.Value + 1 script.Parent:Destroy() end end) end)
Any help is much appreciated as always.
given the comments on your post you'd probably be better off accessing the player via the character
script.Parent.Touched:Connect(function(hit) if hit.Parent.Name == "Pickaxe" then local plr = game.Players:GetPlayerFromCharacter(hit.Parent.Parent) if plr then plr.Backpack.Copper.Value = player.Backpack.Copper.Value + 1 script.Parent:Destroy() end end end)
there's about a million things wrong with the framework of this that I can't be bothered to go into but learning things one thing at a time is probably better anyway aha.