Hey, i am scripting a placing system. I need this remote function to fire once, it is firing many hundreds of times and I figure it is an issue with my UIS code but I have tried and cannot figure it out.
inputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if placingStick == true then
if goodToPlace == true then
local stickCFrame = clientStick.CFrame
placedStructure = stickEvent:InvokeServer(clientStick.Name, clientStick.CFrame)
print("Invoked served")
if placedStructure == true then
placingStick = false
clientStick:Destroy()
end
end
end
end
You should try checking if the UserInputState is equals to Enum.UserInputState.Begin before actually running the code, As any MouseButton1 movement related will always return true - Leading to the code running several times.
inputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if input.UserInputState == Enum.UserInputState.Begin then
if placingStick == true then
if goodToPlace == true then
local stickCFrame = clientStick.CFrame
placedStructure = stickEvent:InvokeServer(clientStick.Name, clientStick.CFrame)
print("Invoked served")
if placedStructure == true then
placingStick = false
clientStick:Destroy()
end
end
end
end
end
end)
Still seems to be funny, i’ve just tried to do something a bit like debounce but It seems I’ve fixed it myself. Thanks for your help though I really do appreciate it