So I am attempting to add a line in a script that increases the player's "Cash" by a specific amount but how do I make the script below a valid member of a player?
game.Players.PlayerAdded:connect(function(plr) local stats = Instance.new("BoolValue",plr) stats.Name = "leaderstats" local cash = Instance.new("IntValue",stats) cash.Name = "Cash" cash.Value = 0 end)
Also, below is the script that I am trying to make give the cash to the player
leave = game.Workspace.leave workspace.NPC1.Head.Dialog.DialogChoiceSelected:connect(function(player,choice) if choice.Name == "Choice1" then --If the player takes the order player.Character.Torso.Anchored = false --Test (does nothing atm) game.Players.LocalPlayer.cash.Value = game.Players.LocalPlayer.Cash.Value +5 wait(3) player.Character.Torso.Anchored = false --Test (does nothing atm) elseif choice.Name == "Choice2" then --If the player does not take the order player.Character.Torso.Anchored = false --Test (does nothing atm) wait(1) player.Character.Torso.Anchored = false --Test (does nothing atm) script.Parent.Parent.Parent.Humanoid.WalkToPoint = game.Workspace.leave.Position wait(5) script.Parent.Parent.Parent:Destroy() end end)
The stats are within the Bool Value you created in the the first block of script
local stats = Instance.new("BoolValue",plr) stats.Name = "leaderstats"
and the stat you have created has the bool value as a parent not the actual player itself so instead of:
game.Players.LocalPlayer.cash
it should be
game.Players.LocalPlayer.leaderstats.Cash
and I've noticed some of it is capitalised and some isnt make sure it is correctly capitalised or it wont work.