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

MouseButton1Click not working on one Local script but works on all the others?

Asked by 3 years ago

So i have multiple Gui buttons that navigate through the menu and i have MouseButton1Click's to do that. Then i have one that is supposed to give your a tool, however that one button doesnt even register its being clicked.

Heres my code for the tool button

local storage = game:GetService("ServerStorage")
local greatSword = storage.GreatSword:Clone()

function leftClick(plr)
    print("equip")
    greatSword.Parent = plr.Backpack
    script.Parent.Visible = false
end

script.Parent.MouseButton1Click:Connect(leftClick)

And this is the code for the normal navigation buttons

script.Parent.Parent.Parent.Weapons.Visible = false

function leftClick()
    script.Parent.Parent.Visible = false
    script.Parent.Parent.Parent.Weapons.Visible = true
end

script.Parent.MouseButton1Click:Connect(leftClick)

The important bits are the functions, i am fairly new to roblox's language of scripting so it could be a simple mistake but i just cant figure out when they both are using the same function code but the tool button one just wont work while the other does.

Also they are buth under frames in the ScreenGui

0
In LocalScript, you can't access the ServerStorage items. Try putting the tool in ReplicatedStorage or Lighting. 9mze 193 — 3y
0
It still isnt doing anything, also i added a print("hello world") right at the very top of the script to see if the script was even running and it didnt show up in the output log, so it looks like that script isnt even running for some reason Voidyll 8 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Figured it out, just needed to move the tool into replicated storage and add a waitforchild before getting the tool from the storage, because what was happening is it was looking for the tool before it was loaded in so it would lock the script.

Thanks to 9mze for the tip

Ad

Answer this question