-
What do you want to achieve? I’m trying to create a chat system in which when a player who has the right rank in a certain group writes !shiftstart, a “stopwatch” will start for all the workers of the group (those workers ranks are >=3) and if the player who said !shiftstart says !shiftend if a worker has been working for more than 8 minutes then they’ll receive a notification and the they’ll be able to end their shift.
-
What is the issue? They are lots of things wrong with my code. 1, the for loop isn’t running. And 2, not sure how to do the timer/stopwatch. Anyways, here’s my code.
game.Players.PlayerAdded:Connect(function(Player)
if Player:GetRankInGroup(12556758) >= 3 then
local WorkerValue = game.ReplicatedStorage.Values.IsWorker
WorkerValue.Value = true
WorkerValue.Parent = Player
end
Player.Chatted:Connect(function(message)
local AdminWhoUsedCMD = game.ReplicatedStorage.Values.AdminWhoUsedCMD
if string.find(message, "!shiftstart") then
if Player:GetRankInGroup(12556758) >= 8 then
AdminWhoUsedCMD.Value = Player.Name
local GrabWorkers = game.Players:GetPlayers()
for i, v in pairs(GrabWorkers) do
local Worker = v:WaitForChild("IsWorker").Value
if Worker == true then
local MinutesEvent = game.ReplicatedStorage.Events.MinutesEvent
local MinutesValue = script.Minutes:Clone()
MinutesValue.Parent = v
local SecondsValue = script.Seconds:Clone()
SecondsValue.Parent = v
while true do
wait(1)
local seconds = 0
local minutes = 0
seconds = seconds +1
if seconds >= 60 then
minutes = minutes +1
seconds = 0
end
MinutesValue.Value = minutes
SecondsValue.Value = seconds
end
end
end
end
elseif string.find(message, "!shiftend") then
local MinutesWorked = Player:FindFirstChild("Minutes")
if Player:GetRankInGroup(12556758) >= 8 then
local GrabWorkers = game.Players:GetPlayers()
for _, v in pairs(GrabWorkers) do
local Worker = v:WaitForChild("IsWorker").Value
if Worker == true then
if MinutesWorked.Value > 8 then
local ShiftEndGui = script.ShiftEnd
ShiftEndGui.Parent = Player.PlayerGui
ShiftEndGui.ShiftEndFrame:TweenPosition(UDim2.new(0.314, 0,0.323, 0), "In", "Quint")
ShiftEndGui.ShiftEndFrame.Handler.Disabled = false
else
print(Worker.Parent.Name.." has not worked 8 minutes, in order for them to end the shift, they need to work for "..8 - MinutesWorked.Value.." more minutes.")
end
end
end
end
end
end)
end)
- What solutions have you tried so far? I haven’t seen anything like this on the DevForum so no, I haven’t found any solutions for this. But, if you know a solution, please let me know!