#how can i prevent spamming on an animation script

41 messages · Page 1 of 1 (latest)

fluid delta
#

add a Cooldown?

worldly plinth
burnt monolith
#

yes @fluid delta

#

should i send u a screenshot of the animation script?

fluid delta
#
local bd

--some event to fire it
if not db then 
  db = true

  --some randum stuff


  wait(sometime)
  db = false
end
burnt monolith
#

at the --some event to fire do i create an event to trigger it?

fluid delta
#

yes

burnt monolith
#

and at the random stuff?

fluid delta
#

there you play your animation

burnt monolith
#

the animation script?

fluid delta
#

ok just send the script

burnt monolith
#

`local Tool = script.Parent
local AnimationR15 = script:WaitForChild("AnimationR15", 1)
local AnimationR6 = script:WaitForChild("AnimationR6", 1)

Tool.Activated:Connect(function()
local Character = Tool.Parent
if Character then
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
if Humanoid then
local LoadedAnim = nil
if Humanoid .RigType == Enum.HumanoidRigType.R15 and AnimationR15 then
LoadedAnim = Humanoid:LoadAnimation(AnimationR15)
elseif Humanoid .RigType == Enum.HumanoidRigType.R6 and AnimationR6 then
LoadedAnim = Humanoid:LoadAnimation(AnimationR6)
end
if LoadedAnim then
LoadedAnim:Play()
end
end
end
end)`

fluid delta
#
local Tool = script.Parent
local AnimationR15 = script:WaitForChild("AnimationR15", 1)
local AnimationR6 = script:WaitForChild("AnimationR6", 1)
local db 


Tool.Activated:Connect(function()
    if db then return end
    db = true

    local Character = Tool.Parent
    local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")

    if not Humanoid then return end

    local LoadedAnim 

    if Humanoid.RigType == Enum.HumanoidRigType.R15 and AnimationR15 then
        LoadedAnim = Humanoid:LoadAnimation(AnimationR15)
    elseif Humanoid.RigType == Enum.HumanoidRigType.R6 and AnimationR6 then
        LoadedAnim = Humanoid:LoadAnimation(AnimationR6)
    end

    if LoadedAnim then
        LoadedAnim:Play()
    end

    task.wait(.1)
    bd = false
end)
burnt monolith
#

thank you

umbral vaporBOT
#

studio** You are now Level 1! **studio

burnt monolith
#

wait is this a local script or a script?

#

cause

fluid delta
#

where is that error?

#

doent look like the roblox otput

burnt monolith
fluid delta
#

thats not the output

#

never used that, maybe just open the output

burnt monolith
#

the script has a little problem

#

it dosen't put a cooldown on it it just lets u push once

#

and then dosen't let u push again

#

or use the tool

#

the push tool

fluid delta
#

try using local db = false at line 4

burnt monolith
#

and i still have a little question

fluid delta
#

?

burnt monolith
#

can u help me put a cooldown on my main script too?

fluid delta
#

ok

burnt monolith
#
    
    local playerRoot = player.Character:FindFirstChild("HumanoidRootPart")
    local pushRoot = toPush:FindFirstChild("HumanoidRootPart")
    
    
    
    if(playerRoot and not playerRoot:FindFirstChild("PushF") and pushRoot and not pushRoot:FindFirstChild("PushF") and (playerRoot.Position - pushRoot.Position).magnitude <= 6) then
        local pushF = Instance.new("BodyVelocity")
        pushF.Name = "PushF"
        pushF.MaxForce = Vector3.new(100000, 100000, 100000)
        pushF.Velocity = (-pushRoot.CFrame.lookVector) * 50
        
        pushF.Parent = pushRoot
        
        wait(0.3)
        
        pushF:Destroy()
    end
end)```
fluid delta
#

where is that script?

burnt monolith
#

in the tool

fluid delta
#

for me the last line is maked red an idk why but try this

local db = false

script.Parent.Push.OnServerEvent:Connect(function(player, toPush)
    
    if db then return end
    db = true
    task.delay(.5, function() db = false end)

    local playerRoot = player.Character:FindFirstChild("HumanoidRootPart")
    local pushRoot = toPush:FindFirstChild("HumanoidRootPart")
    
    if playerRoot and not playerRoot:FindFirstChild("PushF") and pushRoot and not pushRoot:FindFirstChild("PushF") then

        if (playerRoot.Position - pushRoot.Position).Magnitude > 6 then return end

        local pushF = Instance.new("BodyVelocity")
        pushF.Name = "PushF"
        pushF.MaxForce = Vector3.new(100000, 100000, 100000)
        pushF.Velocity = (-pushRoot.CFrame.lookVector) * 50
        
        pushF.Parent = pushRoot
        
        wait(0.3)
        pushF:Destroy()
    end
end)
burnt monolith
#

dsn't work

umbral vaporBOT
#

studio** You are now Level 2! **studio

fluid delta
#

try re coppying it, i missed a "then"

burnt monolith
#

it works thanks