So I’m making a script inside a part where if a player touches this part they will get teleported to another part called “SpawnTP” in-game, I am using the code below but for some reason, it isn’t working? (P.S. please explain thoroughly as I’m not a good scripter)
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild(“HumanoidRootPart”) then
hit.Parent.HumanoidRootPart.Position = script.Parent.Parent.SpawnTP.Position
end
end)
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild('HumanoidRootPart') then
hit.Parent.HumanoidRootPart.CFrame = script.Parent.Parent.SpawnTP.CFrame
end
end)
Try this, If that doesn’t work Please tell me the error.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
--- I recommend make it CFrame
hit.Parent:FindFirstChild("HumanoidRootPart").CFrame = script.Parent.Parent.SpawnTP.CFrame
end
end)