#teleport script

33 messages · Page 1 of 1 (latest)

vocal pecan
#

Hey I made a teleporting script but it won't start. The player is supposed to have 5 items collected and then teleport.

local teleportpart = script.Parent
local pointsIntValue = game.Players:GetPlayers("Items")
if pointsIntValue == 5 then
    teleportpart.Touched:Connect(teleport)
end

function teleport(otherPart)
    local character = otherPart.Parent
    local humanoid = character.Parent:FindFirstChildWhichIsA("Humanoid")
    if humanoid then 
        humanoid.Position = humanoid.Position(387.9, 6.9, -0.1)
    end
end```
somber scaffold
#

hey you can set a humanoids position

#

cant

#

you have to pivot the whole player character

#

so

character:PivotTo(CFrame.new(Vector3.new(387.9, 6.9, -0.1)))
vocal pecan
#

it didn't run

cinder daggerBOT
#

studio** You are now Level 4! **studio

vocal pecan
#

@somber scaffold

somber scaffold
#

?

cinder daggerBOT
#

studio** You are now Level 13! **studio

somber scaffold
#

character:PivotTo

#

the player character is a MODEL

vocal pecan
#

ok but my code doesn't run

#

@somber scaffold how do i get to intvalue inside my player in players?

hollow plover
#

because your function is below it

#

how does the script know what the function is if it's defined after the if statement

#

and you do realise scripts run once if there aren't loops

#

so it checks once and ends

#

and why would you make an if statement before the touched event

#

oh my god

vocal pecan
#

function teleport(otherPart)
    local character = otherPart.Parent
    local humanoid = character.Parent:FindFirstChildWhichIsA("Humanoid")
    local Players = game:GetService("Players")
    local pointsIntValue = game.Players:GetPlayers("Items")
    local itemscollected = pointsIntValue.Value
    print(itemscollected)
    wait(1)
    if humanoid and pointsIntValue == 5 then
        character:PivotTo(CFrame.new(Vector3.new(387.9, 6.9, -0.1)))
        wait(1)
    end
end

teleportpart.Touched:Connect(teleport)```
#

I came up with this but it keeps printing nil even if I collect items

#

@hollow plover

#
    local pointsIntValue = game.Players:GetPlayers("Items")
    local itemscollected = pointsIntValue.Value``` is this correct? I'm trying to get to "Items" intvalue inside my player in players
hollow plover
#

so do you have 5 items when you load in?

vocal pecan
#

no i have 0

hollow plover
#

so show me the script where you get 5 items

vocal pecan
#

Can you help me understand if this part is correct local Players = game:GetService("Players") local pointsIntValue = game.Players:GetPlayers("Items") local itemscollected = pointsIntValue.Value

#

I want to get to intvalue "Items" inside my player in Players

#

and why output prints nil nonstop even if I collect items

#

@hollow plover