How do I teleport the player 10 studs relative to their LookVector? Thanks.
You could just multiply the HumanoidRootPart
’s LookVector by 10 in relative to where its currently looking
Character.HumanoidRootPart.Position = Character.HumanoidRootPart.CFrame.LookVector * 10
Somehow it isnt working it is moving me up instead of forward?
plr.Character:MoveTo(Character.HumanoidRootPart.CFrame.LookVector * 10)
Move to is much more clean and gets the job done better.
That works but there is like a 20 second delay and it is moving the player .3 studs not 10
Ok but why are you referencing the plr variable
Only complaint I have with MoveTo()
is that it corresponds in relation with physics
@JayO_X Could we see the script if possible?
Yea I will my roblox studio is updating on this pc
local chr = plr.Character or plr.CharacterAdded:Wait()
local hrp = chr:WaitForChild("HumanoidRootPart")
plr.Chatted:Connect(function(message)
if message == "lookvector" then
hrp.Position = hrp.CFrame.LookVector * 10
end
end)
This is a LocalScript
, correct?
Not sure if changing it to the server would fix anything, perhaps try this?
local chr = plr.Character or plr.CharacterAdded:Wait()
local hrp = chr:WaitForChild("HumanoidRootPart")
plr.Chatted:Connect(function(message)
if message == "lookvector" then
chr:SetPrimaryPartCFrame(hrp.CFrame * hrp.CFrame.LookVector * 10)
end
end)
local chr = plr.Character or plr.CharacterAdded:Wait()
local hrp = chr:WaitForChild("HumanoidRootPart")
plr.Chatted:Connect(function(message)
local msg = tostring(message) --This worked for me
if msg == "lookvector" then
hrp.CFrame = hrp.CFrame + hrp.CFrame.LookVector * 10
end
end)
The script is in serverscriptservice
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
player.Chatted:Connect(function(message)
if message == "lookvector" then
character:SetPrimaryPartCFrame(character.HumanoidRootPart.CFrame * character.HumanoidRootPart.CFrame.LookVector * 10)
end
end)
end)
Error: Unable to cast Vector3 to CoordinateFrame
This is almost correct, but you are forgetting that you want to teleport them relative to their current POSITION also.
Character.HumanoidRootPart.Position = Character.HumanoidRootPart.CFrame.Position + Character.HumanoidRootPart.CFrame.LookVector * 10
-- An easier solution just using CFrames
Character.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-distance);
It is slightly delayed becuase if you move whilst doing it without cool down the lookvector stays in one place
So make a cool down of such like:
wait(0.25)
Nah. :MoveTo() can move you literally anywhere. Through walls and what not.
it goes as fast as changing position too. Humanoid:MoveTo() is walking. character:MoveTo() is teleporting.
But they both work.
Maybe, but collisions would still be involved if there was something like a thick wall
https://developer.roblox.com/en-us/api-reference/function/Model/MoveTo
Either way it doesn’t really matter
Don’t forget to add CFrame.new() after :SetPrimaryPartCFrame()