I am trying to make a cube flip 90 degrees every time the player jumps, just like Geometry Dash. The cube is the Starter Character. Im using animations, but the animation goes back to idle after the animation is done. But I want the animation to just flip once and stay.
I’m not an expert on animations but my guess is that since it’s an animation it’s supposed to revert back to it’s original position after finishing but I’m not sure. That is why I think you should use tweens instead, since this seems like a something that would suit a tween perfectly, something like this maybe:
-- Server Script in ServerScriptService
local TweenService = game:GetService("TweenService")
local test = workspace.Test
local testCD = test.ClickDetector
local playercd = {}
testCD.MouseClick:Connect(function(plr)
if playercd[plr] == true then return end
playercd[plr] = true
local rotateTween = TweenService:Create(test, TweenInfo.new(0.4), {Orientation = test.Orientation + Vector3.new(0,90,0)})
rotateTween:Play()
rotateTween.Completed:Wait()
playercd[plr] = false
--[[rotateTween.Completed:Connect(function()
tweens also have callback functionality so if
that is of any concern tweens gotchu
end)]]
end)
You can obviously tweak and edit this as much as you want, as this script is by no means perfect I wrote it in like 2 mins, but I think you can see why tweens probably would suit you better than animations. This would of course work with pressing spacebar, I just couldn’t be bothered with setting up a remote event and all that stuff.