Hey!, I Have Made A “Custom” Cube Character.
I’m Wondering How I Could make the Cube (Part) Rotate (Orientate) 360 Degrees when the Player Jumps.
local player = game.Players.LocalPlayer
local Character = player.Character
local Humanoid = player.Character.Humanoid
local debounce = false
Humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if debounce == false then
print("Rotating Player Cube! - Jump Signal")
debounce = true
-- The Rotating / Orientating The Cube Script
wait(1)
debounce = false
end
end)
I’m Going to be Using GetPropertyChangedSignal for This With A Debounce, I just Don’t Know How to make the Cube Part Orientate (Rotate) 360 Degrees
Well, this is really easy. You could probably just use Instance.new(“RotateV”) and then calculate when it reaches 360 degrees.
But, you should probably use some sort of CFrame thing.
local rs = game:GetService("RunService")
local spinRate = 2 * math.pi -- 2pi rad/sec = 1 rotation/sec
local angle = 0
local originalCF = Cube.CFrame
while (angle < (math.pi * 2)) do
local dt = rs.Heartbeat:Wait()
local dTheta = spinRate * dt
angle = angle + dTheta
Cube.CFrame = originalCF * CFrame.Angles(angle, 0, 0) -- modify this if you want a different axis
end
Cube.CFrame = originalCF -- snap to original to make it exactly 360 degrees