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

Spinning part will not work as intended, despite countless attempts to fix it. Help?

Asked by 3 years ago

I have made a mesh spin once a button is pushed. If I leave it alone, it's fine. But I want it to stop spinning after 3 seconds. Everything I do either stops the spinning at the start or ends making the spinning interval 3 seconds. Here is my script, it is not a local script.

t = true

script.Parent.OnServerEvent:Connect(function(Player)
    local parting = Instance.new("Part", workspace)
local around = Instance.new("FileMesh", parting)

parting.Parent = workspace
parting.CFrame = Player.Character.Torso.CFrame*CFrame.new(0,0,-5)
parting.Shape = 1
parting.Anchored = true
parting.Material = "Neon"
    parting.BrickColor = BrickColor.new("Persimmon")
    around.MeshId = "rbxassetid://6981887621"
    around.VertexColor = Vector3.new(0.666667, 0, 0)
    around.Scale = Vector3.new(0.3, 0.3, 0.3)
local cf = CFrame.Angles(0, math.rad(3), 0)

if t then
    wait()
        parting.CFrame = parting.CFrame * cf
        wait(3)

        t = false
        end
    end)

so basically, the script itself works fine. I just can't figure out how to make it spin for 3 second, and stop after 3 seconds.

1 answer

Log in to vote
0
Answered by 3 years ago
local counter = 0

script.Parent.OnServerEvent:Connect(function(Player)
    local parting = Instance.new("Part", workspace)
local around = Instance.new("FileMesh", parting)

parting.Parent = workspace
parting.CFrame = Player.Character.Torso.CFrame*CFrame.new(0,0,-5)
parting.Shape = 1
parting.Anchored = true
parting.Material = "Neon"
    parting.BrickColor = BrickColor.new("Persimmon")
    around.MeshId = "rbxassetid://6981887621"
    around.VertexColor = Vector3.new(0.666667, 0, 0)
    around.Scale = Vector3.new(0.3, 0.3, 0.3)
local cf = CFrame.Angles(0, math.rad(3), 0)

local loop = coroutine.wrap(function()
    while wait(1) do
        counter += 1
    end
end)
loop()

repeat
    wait()
        parting.CFrame *= cf
until counter >= 3
0
it worked, thank u a lot:] Funadonokami 4 — 3y
Ad

Answer this question