The matching video is what I’m trying to achieve, but with CFrames.
Thanks for the help, but your script teleports my character very far away into the void.
The matching video is what I’m trying to achieve, but with CFrames.
Thanks for the help, but your script teleports my character very far away into the void.
Weird, there is no reason to move your character into the void
Can you send the complete Script?
see that little thing at the end of that line? maybe try moving that
I’m not happy to say that the solution is that simple, and I kinda hate myself for that.
What I did was to use CFrame.Angles()
with the HRP
's Orientation
values.
local Pos = CFrame.new(TpPos) * CFrame.Angles(math.rad(HRP.Orientation.X),math.rad(HRP.Orientation.Y),math.rad(HRP.Orientation.Z))
Thanks for the help, @LittleLegender, and @Rami_XD1!
Look, you can simply, do
CFrame.new(Vector3.new(urpos))
The problem is your tween CFrame has no rotation
so the character is slowly rotating to a orientation of 0, 0, 0
local startPosition = StartPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0)
local endPosition = EndPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0)
local positionOffset = endPosition - startPosition
local startCFrame = CFrame.lookAt(startPosition, endPosition)
local endCFrame = startCFrame + positionOffset
HRP.CFrame = startCFrame
local Tween = TweenService:Create(
HRP, TweenInfo.new(Time, Enum.EasingStyle.Linear), {CFrame = endCFrame}
)
They look like the same video to me. I think it’s fine with either.
Hey! Thanks for the help, but it seems like your script does this:
are you talking about the fact that he is going back down once he gets to the top?
I think that is a problem outside of this script for some reason its getting triggered when he gets to the end
No, I mean that from up to down, the character rotates weirdly.
oh I see it are you doing this to go back down
you should be swapping StartPrompt and EndPrompt around like this
local startPosition = EndPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0)
local endPosition = StartPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0)
local positionOffset = endPosition - startPosition
local startCFrame = CFrame.lookAt(startPosition, endPosition)
local endCFrame = startCFrame + positionOffset
HRP.CFrame = startCFrame
local Tween = TweenService:Create(
HRP, TweenInfo.new(Time, Enum.EasingStyle.Linear), {CFrame = endCFrame}
)
The video I sent above is actually representing one of my written issues, what actually happens with your code above is this:
that’s odd because i cant see how my code is doing that
do you mind sharing the code that you have for that last video
This is what I have:
EndPrompt.Triggered:Connect(function(Player)
if CharacterValue.Value then return end
StartPrompt.Enabled = false
EndPrompt.Enabled = false
local Character = Player.Character
CharacterValue.Value = Character
local Humanoid = Character.Humanoid
local Animator = Humanoid.Animator
local HRP = Character.HumanoidRootPart
HRP.Anchored = true
local ZipAnim
local Distance = (Character.HumanoidRootPart.Position - StartZip.NeonCore.Position).Magnitude
local Time = Distance / 25
local Diff = 5
HRP.CFrame = CFrame.new(EndPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0))
HRP.CFrame = CFrame.lookAt(HRP.Position,StartPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0))
local TpPos = StartPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0)
--
local startPosition = StartPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0)
local endPosition = EndPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0)
local positionOffset = endPosition - startPosition
local startCFrame = CFrame.lookAt(startPosition, endPosition)
local endCFrame = startCFrame + positionOffset
--
local Pos = endCFrame
if UsePosition == false then
Pos = CFrame.new(TpPos) * CFrame.Angles(math.rad(HRP.Orientation.X),math.rad(HRP.Orientation.Y),math.rad(HRP.Orientation.Z))
elseif UsePosition == true then
Pos = TpPos
end
local GoalTween
if UsePosition == false then
GoalTween = {
CFrame = Pos
}
elseif UsePosition == true then
GoalTween = {
Position = Pos
}
end
local Tween = TweenService:Create(
HRP,
TweenInfo.new(
Time,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
),
GoalTween
)
--more lines
end)
Your not using endCFrame as the tweens goal
I’ve made some changes so that it uses the endCFrame and this came out:
EndPrompt.Triggered:Connect(function(Player)
if CharacterValue.Value ~= nil then return end
CharacterValue.Value = Player.Character
StartPrompt.Enabled = false
EndPrompt.Enabled = false
local diff = 5
local startPosition = EndPrompt.Parent.WorldPosition + Vector3.new(0, diff, 0)
local endPosition = StartPrompt.Parent.WorldPosition + Vector3.new(0, diff, 0)
local offset = endPosition - startPosition
local tweenTime = offset.Magnitude / 25
local startCFrame = CFrame.lookAt(startPosition, endPosition)
local endCFrame = startCFrame + offset
Player.Character.PrimaryPart.CFrame = startCFrame
local tween = TweenService:Create(
Player.Character.PrimaryPart, TweenInfo.new(tweenTime, Enum.EasingStyle.Linear), {CFrame = endCFrame}
)
tween:Play()
end)
Thank you! I will work on the script when I’ll have more time to organize everything, but I appreciate the help!