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 4 years ago
Edited 4 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 — 4y
0
At line 3, you should connect a function. Dovydas1118 1495 — 4y

2 answers

Log in to vote
0
Answered by 4 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 4 years ago

just needed to connect a function , thanks guys.

Answer this question