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

My Localscript for a SurfaceGUI textbutton isn't working. Suggestions?

Asked by 8 years ago
buy=script.Parent
wep=game.ServerStorage["AK-47"]
price=script.Parent.IntValue.Value

buy.MouseButton1Down:connect(function()
    local user=game.Players.LocalPlayer
    if user.leaderstats.Caps.Value>=price then
        user.leaderstats.Caps.Value=user.leaderstats.Caps.Value-price
        local wepa=wep:Clone()
        wepa.Parent=user.Backpack
    end
end)

There is a tool in serverstorage named AK-47. The localscript is nested in the text button. There is an IntValue in the TextButton. Caps is an IntValue.

Hope this helps.

0
Insert it in a local script ! XToonLinkX123 580 — 8y
0
It is a localscript XtremeSpy 80 — 8y
0
I think that ServerStorage may be the problem. Try inserting the AK-47 into Lighting, and doing it from there. dyler3 1510 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

If FilteringEnabled is turned on, LocalScripts cannot access ServerStorage. In addition, SurfaceGuis do not run on LocalScripts as they are in the workspace and are seen by everyone in the server, not just a singular player individually. A server script would be used for this and would resolve the ServerStorage and the running issues.

If you run into another problem, please let me know and I will find a solution.

0
How would I find the player that clicked the button? XtremeSpy 80 — 8y
0
Nevermind, I figured out you could put it in StarterGui and set the adornee, use localscripts, and have the tools in lighting. Thanks XtremeSpy 80 — 8y
Ad

Answer this question