Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make this teleporter work with local values?

Asked by 7 years ago

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)
0
this should be done on the server using the event http://wiki.roblox.com/index.php?title=API:Class/Player/CharacterAdded User#5423 17 — 7y
0
^ Use the CharacterAdded event and possibly an 'if' statement to check if the Player owns a tycoon. PreciseLogic 271 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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)
Ad

Answer this question