I don't get how it doesn't work, I wanted to make a teleport tool where, where ever you click, you go to
Extra info: btw its a localscript and its in a tool
plr = game.Players.LocalPlayer mouse = plr:GetMouse() script.Parent.Activated:connect(function() plr.Character.Torso.CFrame = CFrame.new(mouse.Hit, mouse.Hit, mouse.Hit) end I thought this would work but it doesn't, it just teleports me to where i spawn in the world when i click it
You're using mouse.Hit wrong! And you're not ending your function the correct way!
If you want to set a CFrame you don't do it like so: CFrame.new(mouse.Hit,mouse.Hit,mouse.Hit)
because that's the same as saying: Vector3.new(part.Position,part.Position,part.Position)
You would only say part2.Position = part.Position
. Also, if you're going to do it this way, use Mouse.Hit.p
because that would turn 9 values into 3.
Can be written in many different ways.
function a() --code end function() --code end event:connect(function() --code end) --Note how it has a closing parenthesis at the end, that's the close the open parenthesis at the beginning
In the way you're writing it you need a ")" after end.
plr = game.Players.LocalPlayer mouse = plr:GetMouse() script.Parent.Activated:connect(function() plr.Character.Torso.CFrame = mouse.Hit.p end)
Hope it helps!
script.Parent.Activated:connect(function(plr) mouse = plr:GetMouse() local tp = player.FindFirstChild("Torso") tp.CFrame = CFrame.new(Vector3.new(mouse.Hit, mouse.Hit, mouse.Hit)) end
That should work better, don't make it a local script. It will find the player, look for their torso, and teleport them. FindFirstChild is a good way for teleportation. It's also shorter than game.Palyer.Localplayer. But if you want it in startergui for what you're doing (because you can't set it to reset gui on spawn if you want), then idk waht to tell ya. Make it a locla script I guess?