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

I am getting random part out of folder and then teleporting player to its location, I got problem?

Asked by 1 year ago
local locations = game.Workspace.Tplocations:GetChildren()
local randomItem = locations[math.random(1, #locations)]
script.Parent.Touched:Connect(function(hit)
    if(hit.Parent:FindFirstChild("Humanoid")) then
        hit.Parent.HumanoidRootPart.Position = Vector3.new(randomItem.Position)
    end
end)


this is the script, I put parts at locations that script randomly chooses single one and spawns player there after touching part, but problem is that everytime player touches part, player always gets teleported to same location and its not at place of any location I put parts at

Answer this question