✓ Accepted answer
I'm not exactly sure if you want it so you can't use it when you're dead or if you just want a cooldown, so I'll try my best to do both.
(Note: My method for making cooldowns is really bad, but my bad method works for this because the cooldown will atleast work on everyone.)
Can't explode on death:
function onChatted(msg, speaker)
source = string.lower(speaker.Name)
msg = string.lower(msg)
if msg == "!explode" then
local human = speaker.Character.Humanoid
if human.Health > 0 then
local boom = Instance.new("Explosion")
boom.Parent = game.Workspace
boom.Position = speaker.Character.UpperTorso.Position
boom.BlastPressure = 5
boom.BlastRadius = 10
end
end
end
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)
Cooldown for explosion (not just can't explode when dead):
function onChatted(msg, speaker)
source = string.lower(speaker.Name)
msg = string.lower(msg)
if msg == "!explode" and not speaker.Character:FindFirstChild("debounceBoom") then
local value = Instance.new("NumberValue", speaker.Character)
value.Name = "debounceBoom"
value.Value = 2
game:service("Debris"):AddItem(value, value.Value)
local boom = Instance.new("Explosion")
boom.Parent = game.Workspace
boom.Position = speaker.Character.UpperTorso.Position
boom.BlastPressure = 5
boom.BlastRadius = 10
end
end
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)
Hopefully any of these 2 work for you. :)
2 comments
tysm i tried looking on the roblox website to see if i could try but couldnt so i truly thank you
you're welcome