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

LocalPlayer shop script help?

Asked by 6 years ago

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)
0
you never said what problems it has F_F 53 — 6y
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 iRoklas 1 — 6y
0
...is it in a localscript? radusavin366 617 — 6y
0
yes, It's a local script in startergui lol iRoklas 1 — 6y
View all comments (2 more)
0
There's no way Vulkarin 581 — 6y
0
So how do you suppose I make a gui shop for my game? I'll pay. iRoklas 1 — 6y

2 answers

Log in to vote
0
Answered by
NajeEod 35
6 years ago
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.

0
Thanks, I’ll try it when I get home. iRoklas 1 — 6y
0
connect is deprecated use Connect User#19524 175 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Put all of the variables in the function.

0
not working iRoklas 1 — 6y

Answer this question