ok so im a beginner scripter and im trying to make a single player tycoon. right now im trying to make a script that adds cash directly from ore to player . i was brainstorming all day how to make it work.
local furnace = script.Parent
wait(1)
local plrname = game.Workspace.PlayerName.Value
furnace.Touched:Connect(function(hit)
if hit.Cash ~= nil then
local player = game.Players.plrname
multiplier = script.Parent.Parent.Multiplier.Value
wait(0.1)
hit.BrickColor = BrickColor.new("Dark stone grey")
wait(0.1)
hit.BrickColor = BrickColor.new("Really black")
wait(0.1)
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + hit.Cash.Value * multiplier
hit:Destroy()
end
end)
plrname is the stringvalue which shows player name
error im getting: 11:07:12.722 - plrname is not a valid member of Players
does anyone know how to fix it?

3 comments
On line 6, do "local player = game.Players:FindFirstChild(plrname)"
You can also use game.Players[plrname]
uh u made this script before in the 2nd page i saw