I'm trying to make a currency system and a button that gives 100 money to the player using this tutorial: http://wiki.roblox.com/index.php?title=In_Game_Currency#Buying_Shirts
but I'm stuck at giving money to the player, I tried making the script that's inside the button fire a server event to the purchasescript:
local click = script.Parent.ClickDetector.MouseClick
local deposit = game.ReplicatedStorage.Deposit
local player = game.Players.LocalPlayer
local payoff = 100
click:Connect(function()
deposit:FireServer(payoff)
end)
and made a function inside purchasescript that gets called on the server event:
local CurrencyManager = require(389753980)
local deposit = game.ReplicatedStorage.Deposit
local currentGold = {}
local updateCur = game.ReplicatedStorage.UpdateCurDis
CurrencyManager:SetInitialFunds(100)
local function onPlayerJoin(player)
CurrencyManager:InitializePlayer(player.UserId)
local balance = CurrencyManager:GetBalance(player.UserId)
currentGold[player.UserId] = balance
updateCur:FireClient(player, balance)
end
local function PayPlayer(player, sum) ~~~~~~~ Function
local balance = CurrencyManager:Deposit(player,sum)
currentGold[player.UserId] = balance
updateCur:FireClient(player, balance)
end
deposit.OnServerEvent:Connect(PayPlayer)
game.Players.PlayerAdded:Connect(onPlayerJoin)
for _, player in ipairs(game.Players:GetPlayers()) do
onPlayerJoin(player)
end
But nothing happens when I click the button, what do I do?
