I want to know where to put an else statement for the Countdown value. Basically I want it so if the command has said, the player has to wait 60 seconds (1 minute) before they can say it again. I’m just not sure where to put the else statement. You can see the script below.
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
local Cooldown = false
-- If the player types "help"
if string.find(message, "!help") then
if Cooldown == false then
local HelpEvent = game.ReplicatedStorage.Events.HelpEvent
local userId = Player.UserId
local HelpGui = script.HelpFrame:Clone()
HelpGui.Name = Player.Name
HelpGui.Parent = Player.PlayerGui.Waiting
HelpGui.Visible = false
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size100x100
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
HelpGui.PlayerIcon.Image = content
HelpGui.PlayerName.Text = Player.Name
if Player:GetRankInGroup(12556758) >= 8 then
local WaitingGui = Player.PlayerGui:WaitForChild("Waiting")
local ScrollingFrame = Player.PlayerGui.HelpGui.Scroll
for i, v in pairs(WaitingGui:GetChildren()) do
v.Parent = ScrollingFrame
v.Visible = true
end
end
end
end
end)
end)
do you want to run the else when they say “!help”? if yes, maybe put it somewhere here?
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
local Cooldown = false
-- If the player types "help"
if string.find(message, "!help") then
if Cooldown == false then
local HelpEvent = game.ReplicatedStorage.Events.HelpEvent
local userId = Player.UserId
local HelpGui = script.HelpFrame:Clone()
HelpGui.Name = Player.Name
HelpGui.Parent = Player.PlayerGui.Waiting
HelpGui.Visible = false
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size100x100
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
HelpGui.PlayerIcon.Image = content
HelpGui.PlayerName.Text = Player.Name
if Player:GetRankInGroup(12556758) >= 8 then
local WaitingGui = Player.PlayerGui:WaitForChild("Waiting")
local ScrollingFrame = Player.PlayerGui.HelpGui.Scroll
for i, v in pairs(WaitingGui:GetChildren()) do
v.Parent = ScrollingFrame
v.Visible = true
end
end
else
--------------here?
end
end
end)
end)
Doesn’t do anything, still runs the same. Here are the changes I made to it.
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
local Cooldown = false
-- If the player types "help"
if string.find(message, "!help") then
if Cooldown == false then
local HelpEvent = game.ReplicatedStorage.Events.HelpEvent
local userId = Player.UserId
local HelpGui = script.HelpFrame:Clone()
HelpGui.Name = Player.Name
HelpGui.Parent = Player.PlayerGui.Waiting
HelpGui.Visible = false
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size100x100
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
HelpGui.PlayerIcon.Image = content
HelpGui.PlayerName.Text = Player.Name
HelpGui.Description.Text = Player.Name.." needs help."
if Player:GetRankInGroup(12556758) >= 8 then
local WaitingGui = Player.PlayerGui:WaitForChild("Waiting")
local ScrollingFrame = Player.PlayerGui.HelpGui.Scroll
for i, v in pairs(WaitingGui:GetChildren()) do
v.Parent = ScrollingFrame
v.Visible = true
v.Handler.Disabled = false
Cooldown = true
end
end
else
wait(60)
Cooldown = false
end
end
end)
end)
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
local Cooldown = false
-- If the player types "help"
if string.find(message, "!help") then
if Cooldown == false then
Cooldown = true
local HelpEvent = game.ReplicatedStorage.Events.HelpEvent
local userId = Player.UserId
local HelpGui = script.HelpFrame:Clone()
HelpGui.Name = Player.Name
HelpGui.Parent = Player.PlayerGui.Waiting
HelpGui.Visible = false
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size100x100
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
HelpGui.PlayerIcon.Image = content
HelpGui.PlayerName.Text = Player.Name
if Player:GetRankInGroup(12556758) >= 8 then
local WaitingGui = Player.PlayerGui:WaitForChild("Waiting")
local ScrollingFrame = Player.PlayerGui.HelpGui.Scroll
for i, v in pairs(WaitingGui:GetChildren()) do
v.Parent = ScrollingFrame
v.Visible = true
end
wait(60)
Cooldown = false
else
wait(60)
Cooldown = false
end
end
end
end)
end)
local Cooldown = false
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
-- If the player types "help"
if string.find(message, "!help") then
if Cooldown == false then
Cooldown = true
local HelpEvent = game.ReplicatedStorage.Events.HelpEvent
local userId = Player.UserId
local HelpGui = script.HelpFrame:Clone()
HelpGui.Name = Player.Name
HelpGui.Parent = Player.PlayerGui.Waiting
HelpGui.Visible = false
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size100x100
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
HelpGui.PlayerIcon.Image = content
HelpGui.PlayerName.Text = Player.Name
if Player:GetRankInGroup(12556758) >= 8 then
local WaitingGui = Player.PlayerGui:WaitForChild("Waiting")
local ScrollingFrame = Player.PlayerGui.HelpGui.Scroll
for i, v in pairs(WaitingGui:GetChildren()) do
v.Parent = ScrollingFrame
v.Visible = true
end
wait(60)
Cooldown = false
else
wait(60)
Cooldown = false
end
end
end
end)
end)
local Cooldown = false
local CooldownTime = 60
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
if string.find(message, "!help") then
if Cooldown == false then
Cooldown = true
local HelpEvent = game.ReplicatedStorage.Events.HelpEvent
local userId = Player.UserId
local HelpGui = script.HelpFrame:Clone()
HelpGui.Name = Player.Name
HelpGui.Parent = Player.PlayerGui.Waiting
HelpGui.Visible = false
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size100x100
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
HelpGui.PlayerIcon.Image = content
HelpGui.PlayerName.Text = Player.Name
if Player:GetRankInGroup(12556758) >= 8 then
local WaitingGui = Player.PlayerGui:WaitForChild("Waiting")
local ScrollingFrame = Player.PlayerGui.HelpGui.Scroll
for i, v in pairs(WaitingGui:GetChildren()) do
v.Parent = ScrollingFrame
v.Visible = true
end
end
wait(CooldownTime)
Cooldown = false
else
print("!help is not available yet because you are on cooldown")
end
end
end)
end)