Problem with script

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
1 Like

You’re waiting 0.05 of a second instead of one second
Change this to while task.wait(1) do.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.