I want to place an object down once then stop the click, I tired to return to break anything else I can do?
I tried a debounce but that just made it fire more than once at the same time, so if I clicked once then it would fire twice, ect.
Code:
local Functions = game.ReplicatedStorage.Functions
local Place = Functions.Place
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local UIS = game:GetService("UserInputService")
local Buttons = script.Parent:GetChildren()
local function PlaceItem(Button)
Mouse.Button1Down:Connect(function()
local Positions = Mouse.Hit.p
Place:InvokeServer(Positions, Button.Tower.Value)
return
end)
return
end
for Index, Button in ipairs(Buttons) do
if Button:IsA("ImageButton") then
Button.MouseButton1Click:Connect(function()
PlaceItem(Button)
end)
end
end