I’m making a mall in my game, and the mall is the place where players can spend their money. I want to make a script that gives a player their pizza if they have 15 or more Cash, but the parts where the Cash value in leaderstats is changed don’t work.
Script:
function Clicked(player)
if game.Players.LocalPlayer.leaderstats.Cash.Value >= 15 then
local y = player.Backpack
local z = game.Lighting["Pizza"]
z:Clone().Parent = y
game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - 15
script.Parent.Purchase:Play()
end
No. Think LocalScript as front-end and the Server Script as the back-end.
I’d use RemoteEvents/RemoteFunctions for this.
May I ask, why are you using LocalPlayer for a server script?
Take a look at this article which explains the client-server model of Roblox. This should help you avoid such mistakes as using localplayer on the server
I’ve posted a solution in my previous reply so give that a look