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

Why is it not teleporting me even know everything is true?

I'm making a script where if a part is touched and the players level is atleast 20 then it will teleport but it's not working.

Here is my script.

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player and player.leaderstats.Level.Value >= 20 then
		hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-397.206, -214.932, -16.744)
		end
	end
end)

2 answers

try it this way? I don't know why but this looks right but yours looks like it should work as well, are you sure the server's leaderstats shows the player's level is higher or equal to 20?

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid') then
          if hit.Parent.Humanoid.Health > 0 then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
               if player.leaderstats.Level.Value >= 20 then
        hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-397.206, -214.932, -16.744)
        end
    end
end
end)

2 comments

0

It's still not working. I think there might be a problem on roblox's side

0

I don't think so, it should work fine. check if your server side's leaderstats, and it should be a server script as well.

Heres what I came up with. If it helped make sure to mark it as answered!

local teleportPart = workspace.TeleportPart

script.Parent.Touched:connect(function(player, hit)
	local humanoid = player.Character.Humanoid
	if humanoid and player.Leaderstats.Level.Value >= 20 then
		humanoid.Parent.UpperTorso.CFrame = CFrame.new(teleportPart.Position + Vector3.new(0,3,0))
	end
end)

I don't know if this will work but thats the general idea of what a working teleport would look like since I used a similar design for one of my projects and with anything that outputs an error, you can probably give it a quick tweak and be on your way. Thanks and remember to mark as answered if it helped! :)

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