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

LocalPlayer shop script help?

So I was writing a script, so far I have a few values in my PlayerScripts like gun1, gun2, gun3 ect so I can reach them in my shop script. Anyways, I'm having a few problems here is my script:

local player = game:GetService("Players").LocalPlayer
local gold = player.leaderstats.Coins
local sp = game.Players.LocalPlayer.PlayerScripts

function buy()
if gold.Value >= 0 then
	gold.Value = gold.Value - 0
	sp.gun1 = true
	end
end


script.Parent.MouseButton1Down:connect(buy)

6 comments

0

you never said what problems it has

0

My problem is it says. 'localplayer is a nil value and my script doesn't work at all. It's a local script in starter gui

0

...is it in a localscript?

0

yes, It's a local script in startergui lol

0

There's no way

0

So how do you suppose I make a gui shop for my game? I'll pay.

2 answers

local player = game:GetService("Players").LocalPlayer
local gold = player.leaderstats.Coins
local sp = player.PlayerScripts

function buy()
if gold.Value >= 0 then
    gold.Value = gold.Value - 0
    sp.gun1 = true
    end
end


script.Parent.MouseButton1Down:connect(buy)

Try this, it should work let me know if it doesn't.

2 comments

0

Thanks, I’ll try it when I get home.

0

connect is deprecated use Connect

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