Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What can I do to prevent this code from placing models over a player's head?

Asked by 6 years ago
local p1 = workspace.Rotationtest
for i = 0,1000000000, .1 do
local cf = p1:GetModelCFrame()
cfLerp = cf:lerp(cf*CFrame.Angles(0,1,0),.05)
game.Workspace.OrderItemR:SetPrimaryPartCFrame(cfLerp)
game.Workspace.OrderItemR:MoveTo(Vector3.new((script.Parent.Primary.Position.X),(script.Parent.Primary.Position.Y),(script.Parent.Primary.Position.Z)))
wait(.01)
end

The code above is designed to make item drops rotate slowly while the player walks around them. While it does exactly what it's supposed to do in isolation, whenever I walk into the space the model is occupying in testing, the model floats up into the air, and stays there, because the script is constantly reading the new Y value each time it loops. I'm not sure what to add to the code to prevent the model from being suspended into the air, nor do I know what to add to prevent the script from moving them up in the first place. Is there any way to fix this?

0
Stop using `MoveTo` if you want it to be able to clip Goulstem 8144 — 6y
0
Ah, that actually worked. Thanks. I originally had placed MoveTo in the script because the base that I was given caused the model to rise into the air while spinning faster and faster. I should have realized that because I've set the threshold really high and the actual rate of rotation very low, that the original issue would not happen anymore. NikoReiesu 0 — 6y

Answer this question