Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this debounce not work properly?

function positionBlock()
	xcoord = math.random(138.5,252.5)
	ycoord = math.random(-19,-18.5)
	zcoord = math.random(-252.5,-137.5)
	luis.Position=Vector3.new(xcoord,ycoord,zcoord)
end
luis = Instance.new("Part",workspace)
luis.Size=Vector3.new(5,1,5)
luis.TopSurface = 0
luis.BottomSurface = 0
luis.Touched:Connect(function(thingTouchingBlock)
	if thingTouchingBlock.Parent:FindFirstChild("Humanoid")then
		positionBlock()
	end
end)
positionBlock()

local fonzi = coroutine.create(function()
    math.randomseed(tick(1)) --Randomize the server's seed (change the pattern of math.random()) 

    while true do
        local randcolor = Color3.fromRGB(math.random(0,255), math.random(0,255), math.random(0,255)) --Randomize three RGB values

        luis.BrickColor=BrickColor.new(randcolor) 
        wait(.2)    
    end 
end)
coroutine.resume(fonzi)
local urmom = false
game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name="leaderstats"
	 points = Instance.new("IntValue",leaderstats)
	points.Name="Buttons Touched" 
	points.Value=0
end)
luis.Touched:Connect(function(thingtouchingblock)
		if thingtouchingblock.Parent:FindFirstChild("Humanoid") and urmom == false then
			points.Value=points.Value+1
			urmom=true
				print("this is working")
		end	
	end)

so I'm more focused on local urmom = false game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name="leaderstats" points = Instance.new("IntValue",leaderstats) points.Name="Buttons Touched" points.Value=0 end) luis.Touched:Connect(function(thingtouchingblock) if thingtouchingblock.Parent:FindFirstChild("Humanoid") and urmom == false then points.Value=points.Value+1 urmom=true print("this is working") end end) So whenever I execute the script and step on the button, it will print and add value, but if I step on the button again it won't do anything. I know that the answer is really simple and that I'm missing something but I can't put my finger on it! please help me everyone here is so helpful <3

1 answer

✓ Accepted answer

u never make urmom false again and u also need a wait() between the true and false

see this article

This discussion is preserved as it was. New answers, comments, and votes are closed.