so when you touch the lava instead of teleporting you to the correct position it teleports you to anything from 1,1,1 to 0,0,0
I cheaked with print spawnposition gives me the right value its something like 256,20ish, 0 and also does hidden value idk whats going wrong
1 | local PlayerService = game:GetService( "Players" ) |
2 |
3 | script.Parent.Touched:Connect( function (hit) |
4 | if hit.Parent:findFirstChild( "Humanoid" ) then |
5 | local HiddenValue = PlayerService:FindFirstChild(hit.Parent.Name).HiddenValues.CurrentLevel.Value |
6 | local SpawnPosition = game.Workspace.Spawns:FindFirstChild(HiddenValue).Position |
7 | hit.Parent.HumanoidRootPart.Position = Vector 3. new(game.Workspace.Spawns:FindFirstChild(HiddenValue).Position) |
8 | end |
9 | end ) |
If you want to teleport a player to this location, you might want to try using CFrame
instead of Position
. Also, just to be safe, I always work with the head of a player, instead of messing with its HumanoidRootPart. This means you might need to add 1 or 2 to the y-value of your location.
1 | local PlayerService = game:GetService( "Players" ) |
2 |
3 | script.Parent.Touched:Connect( function (hit) |
4 | if hit.Parent:findFirstChild( "Humanoid" ) then |
5 | local HiddenValue = PlayerService:FindFirstChild(hit.Parent.Name).HiddenValues.CurrentLevel.Value |
6 | local SpawnPosition = game.Workspace.Spawns:FindFirstChild(HiddenValue) |
7 | hit.Parent.Head.CFrame = CFrame.new(SpawnPosition.Position) |
8 | end |
9 | end ) |
Let me know if this fixed anything.