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

Not getting item nor is my money getting taken when I click buy?

i need help... when i click the buy button the script doesn't work and doesn't take my money or give me the tool

	local Remote = Instance.new("RemoteEvent",game:GetService("ReplicatedStorage"))
	local tools = game.ReplicatedStorage:WaitForChild("Library")
	 
	Remote.OnServerEvent:Connect(function(player,price,tool)
	    local usercash = player.leaderstats:FindFirstChild("Cash")
	    if usercash.Value >= price then
	        usercash.Value = usercash.Value - price
	        tools[tool]:Clone().Parent = player.Backpack
	    end 
	end)

1 answer

on line 7 price doesn't have a variable, you can't deduct a set amount from your players money value without a set value. either add a variable for "price" or set the price yourself.

example:

put this at the top:

local price = 10 -- this is how much of your currency it will deduct, change that to whatever

or replace line 7 with:

 usercash.Value = usercash.Value - 10 -- again, you can change this to the price you want

I hope this helped!

edit: the item isn't being added to your backpack because the error happens at the line above the tool cloning, so after you fix that error you'll get the item in your backpack too. There's nothing wrong with that line.

3 comments

0

I'm still not getting the tool... No errors or nothing :(

0

Make sure it is a local script

0

it still isn't seeming to work...

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