Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script adding cash directly from ore to players cash value doesnt work?

Asked by 4 years ago
Edited 4 years ago

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)
0
When you say it works perfectly do you mean that the value displays as the player's name? If so, try printing the plrname variable to see what it thinks the value is. cmgtotalyawesome 1418 — 4y

Answer this question