I encountered a problem in the script, I want to take away one unit of currency every one second, but it seems to be taken away in a millisecond, I don’t know what the problem is.
--Server
game.ReplicatedStorage.ServerControllers.WantedRobbery.OnServerEvent:Connect(function(plr)
if plr:WaitForChild("BankFolder"):WaitForChild("Wanted").Value >= 1 then
plr.Character.Head:FindFirstChild("Overhead").NamePlr.TextColor3 = Color3.new(0.666667, 0, 0)
plr:WaitForChild("BankFolder"):WaitForChild("Wanted").Value -=1
task.wait(1)
end
if plr:WaitForChild("BankFolder"):WaitForChild("Wanted").Value < 1 then
plr.Character.Head:FindFirstChild("Overhead").NamePlr.TextColor3 = Color3.new(1, 1, 1)
plr:WaitForChild("BankFolder"):WaitForChild("Wanted").Value = 0
end
end)
--Client
while wait(0.05) do
if wanted.Value >= 1 then
wantedFrame.Visible = true
wantedFrame.Title.Text = "You're wanted: "..numberToTime(wanted.Value)
game.ReplicatedStorage.ServerControllers.WantedRobbery:FireServer()
else
wantedFrame.Visible = false
end
end