#script not waiting for remotevent to finish

1 messages · Page 1 of 1 (latest)

minor shale
#
local function rollAnimation(name: string,rarity: number,color: Color3)
    NameText.Position = UDim2.new(0.5,0,0.45,0)
    NameText.Text = name
    NameText.TextColor3 = color
    RarityText.Text = `1 in {rarity}`
    TweenService:Create(NameText, tweenInfo, {Position = UDim2.new(0.5,0,0.5,0)}):Play()
    task.wait(rollSpeed)
end

RollAnimationEvent.Event:Connect(function(name,rarity,color)
    Background.Visible = true
    NameText.Visible = true
    RarityText.Visible = true
    
    for i = 1, math.random(5,10) do --amount of times it rolls before finalizing
        local rand = ChancesModule[math.random(1, #ChancesModule)]
        rollAnimation(rand[1], rand[2],rand[3])
    end
    
    rollAnimation(name,rarity,color)
    task.wait(1)
    Background.Visible = false
    NameText.Visible = false
    RarityText.Visible = false
end)```
#

this is the code of the event being fired

#

issue is that the cooldowntween for the "roll" button shouldnt be played until AFTER the rng rolling animation is played

#

because scripts arent supposed to run until after the event is finished