Hi, I want to do something like this but I think there is a better way than mine. My problem is that i can’t find the exact required force. After a while the coin ends up underground or gradually goes up. I want it smoother and precise
https://gyazo.com/60207cd2f330b2b7e6e70bcc3aec4baa
this is my bodyvelocity:
and the script:
while true do
script.Parent.MaxForce = Vector3.new(1000,348,1000)
wait(3)
script.Parent.MaxForce = Vector3.new(1000,346,1000)
wait(5)
end
I would recommend using TweenService. In that, you can anchor your part and move it in a more controlled way.
All you need to do is get the position of the coin and tween the Y component endlessly. To make it repeat forever, set repeat amount to a negative number like -1. Plus, you need to make it tween back to the original place instead of just teleporting there, so set the next argument to true.
local x, y, z = coin.Position.X, coin.Position.Y, coin.Position.Z
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true, 0)
local pos = {Position = Vector3.new(x, y + 5, z)}
local tween = ts:Create(coin, ti, pos)
tween:Play()
That should work. Obviously you’ll need to set up the X, Y and Z variables yourself when the coin has been created in a specific location, but that’s quite simple.
1 Like