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

Script runs without even clicking a button?

I have a script that has script.Parent:MouseButton1Click:Connect(), but it still runs without the player even clicking the button, how could i fix this problem? There is no error output, it just runs.

local playerGui = game.Players.LocalPlayer:FindFirstChild("playerGui")
local weaponScreen = game.Players.LocalPlayer.PlayerGui:WaitForChild("weaponScreen")
script.Parent.MouseButton1Click:Connect()
game.Players.LocalPlayer.PlayerGui.weaponScreen.Enabled = true
script.Parent.Parent.Parent.weaponScreen.loadoutBG.Visible = false
script.Parent.Parent.Parent.mainOverlay.dBG.Visible = false
script.Parent.Parent.Parent.mainOverlay.wBG.Visible = false
script.Parent.Parent.Parent.mainOverlay.weaponsButton.Visible = false
script.Parent.Parent.Parent.mainOverlay.weaponsButton.Visible = false

2 comments

0

And also, try Connect Function.

0

At line 3, you should connect a function.

2 answers

✓ Accepted answer

Make the Connect() Into a Function, without doing so it would run when you play/test the game.

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