ok so im making a single player tycoon and im trying to make a script that adds cash from ore to player directly. This is my current script and for some reason it doesnt work.

wait(2)
local LocalPlr = game.Players.LocalPlayer.Name
local furnace = script.Parent
furnace.Touched:Connect(function(hit)
	if hit.Cash ~= nil then
		multiplier = script.Parent.Parent.Multiplier.Value
		game.Players.LocalPlr.leaderstats.Cash.Value = game.Players.LocalPlr.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)

2 comments

0

"LocalPlayer" can only be used in LocalScripts, what you can do is store the player's name in a StringValue inside of their tycoon that you can reference as the owner of that tycoon.

0

im gonna try that