I couldn't make a remote event handler with timer. My script is that right now. I want the handler to see when the remote is fired and then it will give me some stats. After that i want it to make a timer in the touched part. I want the timer to -1 every one second. And if the timer is done it will return to normal text. Also if i try to play with it my game crashes. Theres my script right now.

local dab = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local touchedEvent = ReplicatedStorage.Events:WaitForChild("getgift")
    local function onTouchedEventFired(player)
	    local G = player.Gifts
	    local MG = player.MaxGifts
	    if dab == false then
		    dab = true
		    G.Value = MG.Value
		    game.Workspace.getgift.CustomPlayerTag.PlayerName.TextColor3 = Color3.fromRGB(255, 0, 0)
		    game.Workspace.getgift.CustomPlayerTag.PlayerName.Text = 60
		    local timer = Instance.new("NumberValue", game.Workspace.getgift)
		    timer.Name = "timer"
		    timer.Value = 60
		    while true do
			game.Workspace.getgift.timer.Changed:Connect(function()
			    game.Workspace.getgift.CustomPlayerTag.PlayerName.Text = timer.Value
			    wait(1)
		    end)
	    end
	    while true do
			timer.Value = timer.Value - 1
	    end
	    while true do
		    if timer.Value <1 then
			    game.Workspace.getgift.CustomPlayerTag.PlayerName.Text = "GET GIFTS"
			    game.Workspace.getgift.CustomPlayerTag.PlayerName.TextColor3 = Color3.fromRGB(255, 213, 0)
		    end
	    end
    end
end
touchedEvent.OnServerEvent:Connect(onTouchedEventFired)

1 comment

0

robloxwhiz being typical himself, not knowing while loops