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

GUI Button does nothing. No error or anything just nothing happens?

Asked by 7 years ago

Title pretty much says it. Had an old code that was having an error I could not for the life of me figure out why it was occurring there was just no reason it should have been happening. So I made code a little more inefficient but should work because I have done it before. Well now the button does nothing. I tried adding prints throughout to see if it stops somewhere but nothing like it does nothing at all and I can't figure out why. Here's the code:

local but = script.Parent
local gun = but.Parent.Weapon.Value
local wep = game.ReplicatedStorage.Weps
local player = game.Players.LocalPlayer
local pack = player.Backpack

but.MouseButton1Click:connect(function()
    if gun.Value == "MP5K" then
        local clone1 = wep.MP5K:clone()
        clone1.Parent = pack
    elseif gun == "M4" then
        local clone1 = wep.M4:clone()
        clone1.Parent = pack
    elseif gun == "Glock 17" then
        local clone1 = wep.Glock17:clone()
        clone1.Parent = pack
    elseif gun == "AK-12" then
        local clone1 = wep.AK12:clone()
        clone1.Parent = pack
    end
end)

Like is this normal to just have a button do absolutely nothing? This is a local script in the button.

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Don't use MouseButton1Click, use MouseButton1Down. That works best.

Ad

Answer this question