I was making a tool for my RPG (Yes a tool - dw it's the only one in the game) and I made a debounce so I can't spam it, but I can still spam it. Help please! The problem starts on line 61
local tool = script.Parent
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://334670485"
local rand = math.random(1,6)
local player = game.Players.LocalPlayer
function playAnimation(Animation)
local animationTrack = script.Parent.Parent.Humanoid:LoadAnimation(Animation)
animationTrack:Stop()
wait()
animationTrack:Play()
end
tool.Handle.BrickColor = BrickColor.new("Black")
tool.Handle2.BrickColor = BrickColor.new("Really black")
if rand == 1 then
tool.Type.Value = "GreatLightning"
elseif rand == 2 then
tool.Type.Value = "GreatPlasma"
elseif rand == 3 then
tool.Type.Value = "GreatDark"
elseif rand == 4 then
tool.Type.Value = "GreatMoon"
elseif rand == 5 then
tool.Type.Value = "GreatTele"
elseif rand == 6 then
tool.Type.Value = "GreatElemental"
end
if tool.Type.Value == "GreatLightning" then
tool.Handle.BrickColor = BrickColor.new("Steel blue")
tool.Handle2.BrickColor = BrickColor.new("Electric blue")
tool.Handle3.BrickColor = BrickColor.new("Teal")
elseif tool.Type.Value == "GreatPlasma" then
tool.Handle.BrickColor = BrickColor.new("Alder")
tool.Handle2.BrickColor = BrickColor.new("Really red")
tool.Handle3.BrickColor = BrickColor.new("Dark indigo")
elseif tool.Type.Value == "GreatDark" then
tool.Handle.BrickColor = BrickColor.new("Black")
tool.Handle2.BrickColor = BrickColor.new("Black")
tool.Handle3.BrickColor = BrickColor.new("Really black")
elseif tool.Type.Value == "GreatMoon" then
tool.Handle.BrickColor = BrickColor.new("Pearl")
tool.Handle2.BrickColor = BrickColor.new("Butter milk")
tool.Handle3.BrickColor = BrickColor.new("Daisy orange")
elseif tool.Type.Value == "GreatTele" then
tool.Handle.BrickColor = BrickColor.new("Shamrock")
tool.Handle2.BrickColor = BrickColor.new("Pastel green")
tool.Handle3.BrickColor = BrickColor.new("Lime green")
elseif tool.Type.Value == "GreatElemental" then
tool.Handle.BrickColor = BrickColor.new("Bright blue")
tool.Handle2.BrickColor = BrickColor.new("Pearl")
tool.Handle3.BrickColor = BrickColor.new("Electric blue")
end
function redeem()
local debounce = false
if debounce == false then
debounce = true
playAnimation(anim)
wait(5)
for i = 0, 1, 0.1 do
tool.Handle.Transparency = i
wait(0.1)
end
for i = 0, 1, 0.1 do
tool.Handle2.Transparency = i
wait(0.1)
end
for i = 0, 1, 0.1 do
tool.Handle3.Transparency = i
wait(0.1)
end
if tool.Type.Value == "GreatLightning" then
print("GreatLightning") --temp
print("player.leaderstat.Sotsune = GreatLightning") --temp
script.Parent:Remove()
end
if tool.Type.Value == "GreatPlasma" then
print("GreatPlasma") --temp
print("player.leaderstat.Sotsune = GreatPlasma") --temp
script.Parent:Remove()
end
if tool.Type.Value == "GreatDark" then
print("GreatDark") --temp
print("player.leaderstat.Sotsune = GreatDark") --temp
script.Parent:Remove()
end
if tool.Type.Value == "GreatMoon" then
print("GreatMoon") --temp
print("player.leaderstat.Sotsune = GreatMoon") --temp
script.Parent:Remove()
end
if tool.Type.Value == "GreatTele" then
print("GreatTele") --temp
print("player.leaderstat.Sotsune = GreatTele") --temp
script.Parent:Remove()
end
if tool.Type.Value == "GreatElemental" then
print("GreatElemental") --temp
print("player.leaderstat.Sotsune = GreatElemental") --temp
script.Parent:Remove()
end
debounce = false
end
end
tool.Activated:connect(redeem)

1 comment
http://wiki.roblox.com/index.php?title=Debounce