Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this script taking two clicks to activate instead of one?

If it didn't have the Gui part it would work fine but with it it takes two clicks to activate it for some reason, I'm not quite sure what I'm doing wrong.

function onClicked()
	script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked)
	local gui = playerWhoClicked:FindFirstChild("PlayerGui")
	gui.ScreenGui.TextLabel.Text = ("stuff")
	print("other script stuff here")
	end)
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

✓ Accepted answer

You're using the same event twice. You only need one MouseClick event.

script.Parent.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
	local gui = playerWhoClicked:FindFirstChild("PlayerGui")
	gui.ScreenGui.TextLabel.Text = ("stuff")
	print("other script stuff here")
end)

Remember, if FilteringEnabled is enabled, server sided scripts can't access things in the PlayerGui that the server didn't create.

Good Luck!

if I helped, please don't forget to accept my answer.

1 comment

0

Thanks, that seems to have worked!

This discussion is preserved as it was. New answers, comments, and votes are closed.