Help with this coin giving script

Hello Community, I need your help, about this Coins Script, and what happens is that when a person enters the coins script only works for the first person and not for the others.

Script:

WaitTime = 5 
Amount = 1 
function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if (h~=nil) then
		local thisplr = game.Players:FindFirstChild(h.Parent.Name)
		if (thisplr~=nil) then
			local stats = thisplr:findFirstChild("leaderstats")
			if (stats~=nil) then
				local Score = stats:findFirstChild("Level")
				if (Score~=nil) then
					Score.Value = Score.Value + Amount * thisplr.Multiplier.Value
				end
			end
		end
		script.Parent.Transparency = 1
		script.Disabled = true
		wait(WaitTime)
		script.Parent.Transparency = 0
		script.Disabled = false
	end
end

script.Parent.Touched:Connect(onTouched)

Player:

Screenshot_62

You are disabling the script. That means it can’t run anymore to enable itself.

Just disconnect the function when a player touches it and reconnect it after the wait.

local example

local function test()
    example:Disconnect()
    wait(3)
    example = game.Workspace.ChildAdded:Connect(test)
end
example = Game.Workspace.ChildAdded:Connect(test)
3 Likes