Click fires more than once

You can write your topic however you want, but you need to answer these questions:

  1. What i want to achieve is a shop!

  2. Well i have a working script, well not working but… what happens is it fires the clicked event seven times when i only click once, the script isn’t finished i need to make it so you can’t just infinitly click to infinity but it fires the event seven times:

local x = Vector3.new(133.59, 7.185, -180.165)
local y = Vector3.new(133.59, 7.185, -193.539)
local z = x - y
local amn = 5
local truamn = amn - 1
local clicks = 0
print(z)
game.ReplicatedStorage.CameraBuy.OnClientEvent:Connect(function()
	local Part = workspace.stonkies
	local camera = workspace.CurrentCamera
	camera.CameraType = 'Scriptable'
	camera.CFrame = Part.CFrame
	local player = game.Players.LocalPlayer
	player.PlayerGui.GamepassScript.Enabled = false
	player.PlayerGui.Backpack.Enabled = false
	player.PlayerGui.Arrows.Enabled = true
	local arrows = player.PlayerGui.Arrows
	arrows["Arrow Left"].ImageButton.MouseButton1Click:Connect(function()
		clicks -= 1
		local Floored = (math.floor(clicks / 4) + clicks)
		Part.Position += Floored  * z
		camera.CFrame = Part.CFrame
		print(clicks)
	end)
	arrows["Arrow Right"].ImageButton.MouseButton1Click:Connect(function()
		clicks += 1
		local Floored = (math.floor(clicks / 4) + clicks)
		Part.Position += Floored  * z
		camera.CFrame = Part.CFrame
		print(clicks)
	end)
end)
  1. I have no idea what solutions to look for because i haven’t ever seen something like this before :confused:

here’s an image of what happens with one click


as you can see it printed clicked 7 times and moved 7 times the normal amount it should, please help :frowning:

Is it possible that CameraBuy is firing multiple times? That’s the only thing I see that could be going wrong. If its supposed to fire multiple times, then you should move the Connect functions out of the Event function.

Oooooooooooo thanks ill check it now and tell you what happens!

Thank you! It worked. I just added a debounce to the CameraBuy Event.