im a beginner and im making a single player tycoon game and im trying to make a script that adds the cash directly from ore to players cash. Heres the script:
wait(2) local plrname = game.Workspace.PlayerName.Value local furnace = script.Parent furnace.Touched:Connect(function(hit) if hit.Cash ~= nil then multiplier = script.Parent.Parent.Multiplier.Value game.Players.plrname.leaderstats.Cash.Value = game.Players.plrname.leaderstats.Cash.Value + hit.Cash.Value * multiplier wait(0.1) hit.BrickColor = BrickColor.new("Dark stone grey") wait(0.1) hit.BrickColor = BrickColor.new("Really black") wait(0.1) hit:Destroy() end end)
plrname is a stringvalue in workspace which shows the players name. It works perfectly but the script doesnt detect its value for some reason.
This one doesnt work aswell:
wait(2) local plrname = game.Workspace.PlayerName.Value local furnace = script.Parent furnace.Touched:Connect(function(hit) if hit.Cash ~= nil then multiplier = script.Parent.Parent.Multiplier.Value game.Players(plrname)leaderstats.Cash.Value = game.Players(plrname)leaderstats.Cash.Value + hit.Cash.Value * multiplier wait(0.1) hit.BrickColor = BrickColor.new("Dark stone grey") wait(0.1) hit.BrickColor = BrickColor.new("Really black") wait(0.1) hit:Destroy() end end)