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

A script that teleports the player on touched. wont work?

 local debounce = false
script.Parent.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if debounce == false then
        if player.Atlantis.Value ~= nil then
            if player.Atlantis.Value == true then
                hit.Parent.HumanoidRootPart.Position = Vector3.new(game.Workspace.Teleporttoatlantis.Position.X, game.Workspace.Teleporttoatlantis.Position.Y, game.Workspace.Teleporttoatlantis.Position.Z)
                debounce = true
                wait(5)
                debounce = false
            end
        end
    end
end) 

1 comment

0

What are you trying to do at line 5 and 6 ?

1 answer

The fault is very likely at line 5 and 6. Roblox doesn't put any values within the Player in Players. Your best bet is to put your "Atlantis" value within "game.StarterPlayer.StarterPlayerScripts" and instead do the following:

if player.PlayerScripts.Atlantis ~= nil then --Do not use "if player.Atlantis.PlayerScript.Value ~= nil" as this means something else
if player.PlayerScripts.Atlantis.Value == true then --Here you're comparing its value

if you have any questions or issues contact me. ;)

2 comments

0

ah, i was so tired last night could not even tell what i was doing wrong.

0

If this resolved your issue please mark it as answered so people don't think this is still unanswered.

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