Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is the reason this script is not working because roblox updated the system?

This is an item shop script

local player = game.Players
Cash = script.Parent.Parent.Parent.Parent.Parent.RealMoney
local tool = game.Lighting.Spas12
function onClick()
	if Cash.Value >= 10 then
		Cash.Value = Cash.Value - 10
			local clone = tool:Clone()
            clone.Parent = player.Backpack
                    
	end
end

script.Parent.MouseButton1Click:connect(onClick)


the leaderboard

local rs = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(plr)
	local ls = Instance.new("IntValue", plr)
	ls.Name = "leaderstats"
	local rc = Instance.new("NumberValue", plr)
	rc.Name = "RealMoney"
	local c = Instance.new("StringValue", ls)
	c.Name = "Money"
	c.Value = "$"..rc.Value
	c.Value = 10
	rc.Value = 10
	

13 comments

1

Put Spas12 in ReplicatedStorage instead of Lighting.

0

ok ill try

0

The reason is because "player" is the game.Players not the actual person who is playing

0

game.Players is where all the players are located, not the specific player.

0

What should I replace it with ?

0

What is script.Parent?

0

That line is the players money

0

Can I see the Leaderboard/Leaderstats script?

0

the problem with the orig script wasn't the cash, but the tool didn't go into the players backpack

0

The cash has to do with the tool going in the backpack.

0

Can I see thew Leaderboard/Leaderstats script?

0

ok

0

I edited my answer. Hope it works!

1 answer

✓ Accepted answer

Put Spas12 in ReplicatedStorage and put the script in the model and put a ClickDetector in the model. I'm not sure this will work:

local tool = game.ReplicatedStorage.Spas12
-- put Spas12 in ReplicatedStorage
function onClick(plr)
    if plr.leaderstats.Realmoney.Value >= 10 then
        plr.leaderstats.RealMoney.Value = plr.leaderstats.RealMoney.Value - 10
            local clone = tool:Clone()
            clone.Parent = plr.Backpack

    end
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)

9 comments

0

Reply in the comments if it doesn't work. Also, cash is the leaderstat, right?

0

cash is in the player

0

That is the cash's parent exactly?

0

Sorry this didn't work, the problem with the orig script wasn't the cash, but the tool didn't go into the players backpack

0

Sorry this didn't work, the problem with the orig script wasn't the cash, but the tool didn't go into the players backpack

0

The cash has to do with the tool going in the backpack.

0

Thx it worked!!

0

You're welcome.

0

:D

This discussion is preserved as it was. New answers, comments, and votes are closed.