I'm trying to make a simulator game and I've started by making a sell pad that's supposed to trade your Breaths for Money (1:1 ratio). When I step on the sell pad, the money should be set to the breaths and the breaths should be set to 0. I added print statements in the function to troubleshoot so I know that the Touched event is working but the leaderstats aren't changing. I even printed the leaderstats to make sure that they weren't changing. Sell Platform Script:
local part = script.Parent
part.Touched:Connect(function(part)
if (game.Players:GetPlayerFromCharacter(part.Parent))
then
print("Touched by player!")
local player = game.Players:GetPlayerFromCharacter(part.Parent)
player.leaderstats.Money.Value = player.leaderstats.Breaths.Value
player.leaderstats.Breaths.Value = 0
end
end)
Leaderstats Script:
function playerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local breaths = Instance.new("IntValue")
breaths.Name = "Breaths"
breaths.Value = 0
breaths.Parent = leaderstats
local money = Instance.new("IntValue")
money.Name = 'Money'
money.Value = 0
money.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(playerJoin)

2 comments
are both script's server sided?
Yes, they're both scripts. The leaderstats is in ServerScriptStorage and the Sell Platform script is in a Part