#i need help
34 messages · Page 1 of 1 (latest)
no
the script works but everytime the i loop is done the orientation resets to the default orientation
What is the value of "maxDistance " it isn't in the script?
its the local Distance i just accidentally removed the max while writing the message
** You are now Level 1! **
local lookat =CFrame.lookAt(script.Parent.Position, nearestPlayer.Character.Head.Position)
script.Parent.CFrame = CFrame.new(script.Parent.Position):Lerp(lookat, i)
end
script.Parent.CFrame = CFrame.lookAt(script.Parent.Position, nearestPlayer.Character.Head.Position)```
Line 23-26.
There is some repeating code, first it tries to lerpt it with a position then it just sets it for some reason.
This might be the issue.
@sterile hatch
thats the script that moves the orientation to look at the player the thing im confused about is when that i loop is over the orientation resets wich is wy there is a second lookat because i tried to fix the problem
im trying to make the orientation not reset when the i loop is over
I know, the lookAt under that might reset it.
What is the reason for the second lookAt?
What are you trying to achieve with it?
my thought was that the orientation might reset because of the i loop ending wich is why i tried to set the orientation to look at the player after the i loop to make it look at the player again
I will try removing it in my studio copy and give you an update.
It doesn't seem to be the issue.
@sterile hatch Will adding more wait, I saw the part is turning 180 degress in the same direction everytime.
Oh it was just the original starting point.
@sterile hatch I removed the lerp and set directly the lookAt CFrame. The lerp seems to be the problem.
yes i know but what im wondering if theres a way i can have the lerp but not have it reset everytime
Is there any reason, why you are using this over tween service?
TweenService works smoother for animations.
And is simplier.
honestly i just didnt know tween service is a thing
Try it.
i'll try to implement it i guess
thank you
i tried making it a tweenservice but i got the error unable to cast to discitonary
local Players = game:GetService("Players")
local part = script.Parent
local tweenservice = game:GetService("TweenService")
local maxDistance = 50
local info = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
while true do
wait(0.01)
local nearestPlayer, nearestDistance
for _, player in pairs(Players:GetPlayers()) do
local character = player.Character
local distance = player:DistanceFromCharacter(part.Position)
if not character or
distance > maxDistance or
(nearestDistance and distance >= nearestDistance)
then
continue
end
nearestDistance = distance
nearestPlayer = player
local goal = {CFrame.lookAt(script.Parent.Position, nearestPlayer.Character.Head.Position)}
local twoon = tweenservice:Create(script.Parent, info, goal)
twoon:Play()
end
end
@gaunt adder local twoon = tweenservice:Create(script.Parent, info, goal) this returned unable to cast to discionary
@sterile hatch You have to do goal.CFrame = CFrame.lookAt(script.Parent.Position, nearestPlayer.Character.Head.Position)
I would also name the table goals, as it can have multiple goals.
i know i've already fixed it
Everything working now?
yeah