When you click with this tool, player move to that red block. --Vector3.new(0,20,0)
First try : worked well. Character moved to point smoothly.
After second : not good. When tweenservice begin, position and angle of character changed randomly. It only works well again through reset. What should I do?
.
.
.
Here’s script of tool. pls help
local Character = Player.Character
function Activated()
print(script.Parent.Parent.Name)
if Player.Character.Humanoid.FloorMaterial.Name ~= "Air" then
Tool.Enabled = true
tak()
end
end
function tak()
Player.Character.Head.Anchored = true
tweeninfo = TweenInfo.new(6,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
goal = {
Position = Vector3.new(0,20,0)
}
tween = TweenService:Create(Player.Character.Head,tweeninfo,goal)
tween:Play()
task.wait(9)
Player.Character.Head.Anchored = false
end
Tool.Activated:connect(Activated)
You’re tweening to Position instead of the CFrame. So, my assumption is that the CFrame of the character, probably the rotation values specifically, are set and staying that way until after the tween is done and the player is unanchored.
What caused the player to snap upside-down, or turning in odd ways, was probably due to collision issues or something when snapping the players position after moving.
Solution?
You could tween the player’s CFrame instead of the Position. This way you have more control over where the player is facing/is. You could tween the character from where they start to then end by staring at the end parts CFrame, or something else entirely.
Maybe setting the CFrame of the player to face the part on the X and Y, not the Z-axis, and then tweening the position would get the result you want.
I hope that make sense, probably too many words to just stay “use CFrame”.