Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

3 comments

0

Insert it in a local script !

0

It is a localscript

0

I think that ServerStorage may be the problem. Try inserting the AK-47 into Lighting, and doing it from there.

1 answer

✓ Accepted answer

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.

2 comments

0

How would I find the player that clicked the button?

0

Nevermind, I figured out you could put it in StarterGui and set the adornee, use localscripts, and have the tools in lighting. Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.