Hi there i'm a little stuck on how i would set a players cash through a admin gui i'm not to familiar with this language and could use a little help. here is what the gui looks like
here is what i have so far not sure if im on the right lines or not aha
button = script.Parent.MouseButton1Click:connect(function()
local stat = Instance.new("IntValue")
stat.Parent = script.Parent.Parent.casgplayertext.Text
stat.Name = "Cash"
stat.Value = script.Parent.Parent.cashetxt
game.Players.childAdded:connect()
end)
The statistics values should be children of a model or folder object named 'leaderstats', located in the player (for instance: Player1>leaderstats>Cash). So you need a script that creates this 'leaderstats'-named object with the statistics you want. So you would get something like this:
local players = game:WaitForChild("Players")
local function initializeLeaderstats(player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
local cashStat = Instance.new("IntValue", stats)
cashStat.Name = "Cash"
stats.Parent = player
end
players.PlayerAdded:connect(initializeLeaderstats)
Then you need some code to manipulate the value of someones cash statistic in another script. You can write a function that uses 2 parameters: the player name and the amount of cash.
local players = game:WaitForChild("Players")
local function setCashValue(playerName, value)
local player = players:FindFirstChild(playerName)
if player then
local leaderStats = player.leaderstats
local cashStat = leaderStats.Cash
cashStat.Value = value
end
end
You can call this function when you have clicked the 'Submit' button with the 2 parameters: the player name and the amount of cash.