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

How would I make this teleporter work with local values?

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)

2 comments

0

this should be done on the server using the event http://wiki.roblox.com/index.php?title=API:Class/Player/CharacterAdded

0

^ Use the CharacterAdded event and possibly an 'if' statement to check if the Player owns a tycoon.

1 answer

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)

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