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
try using debounce