Hello everyone, I’ve got a rather odd situation. I have a problem with ClickDetectors
and them triggering twice, I’ve tried adding a dbounce
clause and it still duplicates the expected result which in this case is a helicopter. When I press on the button to spawn said helicopter it is meant to clone one from ServerStorage
into the game world at the position it was originally located at. My issue is when using :Clone()
or even a print("Test")
inside of the MouseClick
function the intended output is duplicated.
As you can see here the expected output “Cloned new” is duplicated. The object is cloned twice as well as seen here
I’ve searched through the Wiki as well as these forums for this particular issue and I’ve come up completely empty as to why a ClickDetector
would duplicate the function contents leading to a duplicated result. I’m experiencing a similar issue with ClickDetectors
that give players tools. Depending on the session it may only spawn once; however, a majority of the time it is duplicated twice. I was wondering if anyone has any insight into this issue if you’ve experienced it before.
Code for Spawn Button
This is located inside of a ServerScript in the spawn button part.
local ClickDetector = script.Parent:WaitForChild('ClickDetector')
local CanRegen = script.Parent:WaitForChild('CanRegen')
local HelicopterKit = game.ServerStorage.Helicopters.Plot_One:WaitForChild("Military_Helicopter")
local CurrentHelicopter --= HelicopterKit:Clone()
ClickDetector.MouseClick:Connect(function(Player)
if script.Parent.Parent.Parent.isPurchased.Value == true and CanRegen.Value == true then
if CurrentHelicopter ~= nil then
CurrentHelicopter:Destroy()
CurrentHelicopter = HelicopterKit:Clone()
CurrentHelicopter.Parent = script.Parent.Parent.Parent.Parent.Parent.Parent.Helicopters
CurrentHelicopter:WaitForChild('Required'):WaitForChild('DriverSeat'):WaitForChild('Heli_SControl').Disabled = false
print("Destroyed old, and cloned new")
else
CurrentHelicopter = HelicopterKit:Clone()
CurrentHelicopter.Parent = script.Parent.Parent.Parent.Parent.Parent.Parent.Helicopters
CurrentHelicopter:WaitForChild('Required'):WaitForChild('DriverSeat'):WaitForChild('Heli_SControl').Disabled = false
print("Cloned new")
end
end
end)
I’m sure it’s a really silly error but I can’t for the life of me figure it out, anyways, thank you in advance.