Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script runs without even clicking a button?

Asked by 3 years ago
Edited 3 years ago

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
0
And also, try Connect Function. CodedStars 70 — 3y
0
At line 3, you should connect a function. Dovydas1118 1495 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

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

Ad
Log in to vote
0
Answered by 3 years ago

just needed to connect a function , thanks guys.

Answer this question