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

I need help with mousebutton1Down please?

I made this script when I press my mouse button it changes the nozzle color to red and it should spray red paint and when I let go of my mouse button it should stop but for some reason when I click the the button the nozzle turns red but nothing is spraying , but when I let go of my mouse button that is when the paint starts to spray can someone help me thank you :)

here's the code

nozzle = script.Parent
mouse = game.Players.Player1:GetMouse()
spraying = false

function sprayingg()
	if spraying == false then
		spraying = true
		if spraying then
			print("Spraying")
			while spraying do
				nozzle.BrickColor = BrickColor.Red()
				wait()
			end
		end
	end
end

function sprayPaint()
	if spraying == false then
		spraying = true
		while spraying do
			paint = Instance.new("Part",Workspace)
			paint.BrickColor = BrickColor.new(21)
			paint.FormFactor = Enum.FormFactor.Custom
			paint.Size = Vector3.new(1, 0.2, 0.6)
			paint.Position = mouse.Hit.p
			wait()
			end
		end
end

mouse.Button1Down:connect(function()
	sprayingg()
	sprayPaint()
end)

mouse.Button1Up:connect(function()
	if spraying == true then
		spraying = false
		if not spraying then
			print("Not spraying")
			nozzle.BrickColor = BrickColor.new("Institutional white")
			
		end
	end
end)

1 answer

wait is the sprayingg supposed to be like that?? and i think you need to get rid of"Player1"

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