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

Gun buying script inside GUI won't work?

Asked by 7 years ago

Hello, there everybody I am currently having issues with a script I made a few minutes ago and can not figure out why it won't work the GUI is inside lighting and when someone walks up to the counter it gives them the GUI yet that is not the issue the issue is on line 2 of the script I think as player is a nil value?

    local player = game:GetService("Players").LocalPlayer
    local money = player:WaitForChild("Money")

function onClick()
if player.leaderstats.Profession.Value == "Officer" then
    if money.Value >= 500 then
        money.Value = money.Value - 500
            local M16 = game.ServerStorage.M16:clone()
            M16.Parent = script.Parent.Parent.Parent.Parent.Parent.Backpack
            script.Parent.Parent.Visible = false
            script.Parent.Parent.Parent.Good.Visible = true
       else
            script.Parent.Parent.Visible = false
            script.Parent.Parent.Parent.Error.Visible = true
    end
  end
end
script.Parent.MouseButton1Click:connect(onClick)

If someone could help me out and help me learn from the mistake that would be great!

1 answer

Log in to vote
2
Answered by 7 years ago

Needs to be in a local script, I believe.

1
More along the lines of "Has to be in a local script or it will not work" IcyEvil 260 — 7y
Ad

Answer this question