Im working on a simulator and im kinda new to scripting , i wanted to make one of those portals you touch with the body and get teleported at specific coordonates , but it doesnt work
game.Workspace.Player.HumanoidTouchPart.CFrame = CFrame.new(Vector3.new(-69, 0.5, -171))
What am i doing wrong?
You can't specify a player like that, everything else seems ok. This is how you can do it in localscripts:
local Player = game.Players.LocalPlayer Player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(-69, 0.5, -171))
you need to do PlayersCharacter.HumanoidRootPart.CFrame = Cframe
so do it like this:
local teleporter = --part to touch teleporter.Touched:Connect(function(part) if(part.Parent:FindFirstChild("Humanoid")) then part.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(-69, 0.5, -171)) end end)
Try this:
local StartingPart = game.Workspace.StartingPart --change if needed local TeleportingPart = game.Workspace.TeleportingPart -- part you're teleporting to, change if needed StartingPart.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent:FindFirstChild("HumanoidRootPart").CFrame = TeleportingPart.CFrame end
What you'll need to do is have a part that this runs when you touch it, and a part for it to teleport you to. So, when you touch the StartingPart it'll teleport you to the CFrame of the TeleportingPart.
Happ scripting, be sure to mark as the answer if this helps!
Try:
local player = game.Players.LocalPlayer TeleportCoordinates = () --Put coords in the () player.Character.HumanoidRootPart.CFrame = CFrame.new(TeleportCoordinates)
To get coordinates you could
Do "print(player.Character.HumanoidRootPart.CFrame)"
or
Make a textlabel and make it loop with
local player = game.Players.LocalPlayer while true do wait() --make sure to add the wait or it will crash your game :D script.Parent.Text = player.Character.HumanoidRootPart.CFrame end