Once the player dies they spawn on this brick but I want it to immediately teleport them back to their planet if their Owned Tycoon value in leaderstats is = to 1.
How would I do that if scripts cant work in server mode using "LocalPlayer"?
It works in studio mode but not in server mode. i need it to work in server mode!
Here is my original script --
script.Parent.Touched:connect(function(hit) if game.Players.LocalPlayer.leaderstats.HasTycoon.Value == 1 then if hit.Parent.Humanoid ~= nil then hit.Parent.Torso.CFrame = CFrame.new(54, -38.5, 1518) end end end)
This script is correct you are just finding the player illegally in this case. Instead of...
script.Parent.Touched:connect(function(hit) if game.Players.LocalPlayer.leaderstats.HasTycoon.Value == 1 then if hit.Parent.Humanoid ~= nil then hit.Parent.Torso.CFrame = CFrame.new(54, -38.5, 1518) end end end)
do this...
script.Parent.Touched:connect(function(hit) if game.Players[hit.Parent.name].leaderstats.HasTycoon.Value == 1 then -- Use hit.parent.Name to identify the play, not LocalPlayer! if hit.Parent.Humanoid ~= nil then hit.Parent.Torso.CFrame = CFrame.new(54, -38.5, 1518) end end end)