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

Why is this purchase script I made not working?

How is this not working? No errors in output or script analysis. No cash is being deducted from the player neither is the item being given. Please help!

price = 100
item = game.Lighting.SpeedCoil
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	if plr.leaderstats.Coins.Value >= price then
		plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - price
		item:Clone().Parent = plr.Character
	end
end)

3 comments

0

Im not sure, but try putting the speed coil gear inside of ServerStorage, then, im pretty sure that you want to put the item inside of the players backpack not character, though im not sure because i havent worked much with gears, so maybe for a start try giving your player the item with the part of the script that gives the player the item (item:Clone)

0

Try debugging to see if the code reaches till line 5.

0

And could also be possible that you don't have enough coins (100) in your leaderstats. Maybe you have less than that.

1 answer

✓ Accepted answer

Change line 6 to this:

item:Clone().Parent = plr.Backpack
item:Clone().Parent = plr.StarterGear

And it's better if you save the tool in replicated storage not lighting.

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