I’m trying to make this selection system. Everything seems to work except the actual clicking. Sometimes I see only one click meaning it works properly, other times I get several clicks which cancel out my function. I’ve tried adding a debounce but that seems to have no effect. I want to use click detectors so that I have an easy way for all platforms to interact.
Here is a clip of me interacting with my item, I only click the thing around 6 times here and there. If it registers an even amount of clicks at the same time the billboard GUI doesn’t display.
Despite the few clicks I actually did my print statement is run 44 times, with each click giving me an inconsistent number of prints. Sometimes 1 (which is good), sometimes 4, sometimes even up to 7 or more.
![]()
I do not know if this changes anything but this script (Selection Script) is under StarterGui
I cut some code out and this is everything related to the click detectors. This code is a part of a local script and no other script uses these click detectors.
clickDetector.MouseClick:Connect(function()
if db == true then
--nothing
end
db = true
print("clicked")
if object:HasTag("NameCheckable") then
if nameTag.Adornee == object then
nameTag.Adornee = nil
nameTag.Enabled = false
else
nameTag.Adornee = object
nameTag.Enabled = true
nameTag.Frame.TextLabel.Text = object.Name
nameTag.Frame.TextLabel.MaxVisibleGraphemes = 0
nameTag.Frame.Position = UDim2.new(0, 0, -0.05, 0)
nameTag.ImageLabel.Position = UDim2.new(0.5, 0, 0.45, 0)
nameTag.Size = UDim2.new(4 + (0.6 * math.max(0, object.Name:len() - 4)), 0, 2, 0)
nameTag.StudsOffsetWorldSpace = Vector3.new(0, object.Size.Y / 2, 0)
tweenService:Create(nameTag.ImageLabel, TweenInfo.new(0.25, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out), {Position = UDim2.new(0.5, 0, 0.5, 0)}):Play()
tweenService:Create(nameTag.Frame, TweenInfo.new(0.25, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out), {Position = UDim2.new(0, 0, 0, 0)}):Play()
tweenService:Create(nameTag.Frame.TextLabel, TweenInfo.new(0.25, Enum.EasingStyle.Linear), {MaxVisibleGraphemes = utf8.len(object.Name)}):Play()
end
end
task.spawn(function()
task.wait(0.1)
db = false
end)
end)
clickDetector.MouseHoverLeave:Connect(function(plr)
container.Parent = plr.PlayerGui
gui.Enabled = false
userInputService.MouseIconEnabled = true
nameTag.Adornee = nil
nameTag.Enabled = false
end)
If anybody can help make my click detectors consistent that would help out a lot. If more information is needed feel free to ask me.
