So, I am trying to create a script that will teleport the player
when he touches a certain block in-game. Pretty easy right?
I don’t think it should be hard to do, but for some reason the game decides
to kill the player after moving them to the given location
the script i use:
local door = script.Parent
door.Touched:Connect(function(player)
if player.Character.HumanoidRootPart then
player.Character.HumanoidRootPart.CFrame = CFrame.new(-1183.74, 759.296, -589.548)
end
end)
I have tried some solutions from already existing topics on the internet, have watched
some tutorials about onTouch and Touch events but sadly enough, they didn’t solve my
problem, also tried adding a statement that would change the player’s health after being moved,
I tried working with parts or spawns instead of CFrame/Vector3
solutions I already tried:
localteleportpart = script.Parent -- The part you want to teleport the player
teleportpart.Touched:Connect(function(hit)
if hit.Parent.HumaniodRootPart then
hit.Parent.HumanoidRootPart.Position = Vector3. new(0,0,0) -- What ever X,Y,Z you want`
end
end)
place = CFrame.new(0,0,0)--where you want the player to go when touched
script.Parent.Touched:Connect(function(p)
local humanoid = p.Parent:FindFirstChild("Humanoid")
if (humanoid ~nil) then
humanoid.Torso.CFrame = place
end
end)
^ this one didn’t work as i’m working with R15 and this was made for R6
I am pretty new to all this so I would defenitely appreciate it
if explenations can be kept simple, I’m still learning all the terms used on this forum
(I prefer explanation before scripts are given out as I’m still learning and don’t want to lean on others too much)