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

How to stop remote event firing 249 times in 5 clicks?

When I use the code below, my remote event seems to be fired 249 times within 5 clicks for a reason I don't understand. Would it do with me using a while wait() do loop?

if Mouse.Target then
		if Mouse.Target.Name == "Base" and Mouse.Target.Parent.Name == game.Players.LocalPlayer.Name then
			local X = round(Mouse.Hit.X)
			local Z = round(Mouse.Hit.Z)
			Model:SetPrimaryPartCFrame(CFrame.new(X,8.5,Z))
			for i,v in pairs(Model:GetChildren()) do
				if v.Transparency == .5 then
					break
				else
					v.Transparency = .5
					v.CanCollide = false
				end
			end
			Mouse.Button1Down:Connect(function()
				--[[local NewModel = Model:Clone()
				for i,v in pairs(NewModel:GetChildren()) do
					v.Transparency = 0
					v.CanCollide = true
				end
				NewModel.Parent = game.Workspace.Tycoons[game.Players.LocalPlayer.Name] --]]
				print(game:GetService("ReplicatedStorage").Place:FireServer(Mouse.Hit.X, Mouse.Hit.Z, "Test"))		
			end)
		elseif Mouse.Target.Name == "Hitbox" then
			Mouse.Button1Down:Connect(function()
				if Mouse.Target.Transparency == 0 then
					Mouse.Target.Parent:Destroy()
				end
			end)
		end
	end

1 comment

1

try using debounce

1 answer

Use a debounce so that it doesn't repeat itself

1 comment

0

This should be a comment.

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