Sell Part Not working

I want to make A sell part But its not working Plz tell where i am wrong
Code:
image

1 Like

Are you getting an errors or warnings?

Is this a local script or a normal script?

@Amaan707

It is a Local script. I always use Local scripts and Not normal scripts

Is the localscript in workspace by any chance? If so, convert to a regular script please, localscripts will not run there

Its still not working even in normal script

Where is the script located? And are you getting any errors/warnings?

Make sure the part it’s in is anchored. If it’s not then it could be falling and being deleted

inside the part n there r n errors

The part is anchored its still not working

Put a print statement after every if statement and tell me the output

This script should be a Script and not a LocalScript, since this should run on the server (not on the client). A ‘sell part’ has nothing to do with only one player, but rather with all players in the server.

The script looks fine to me. Things that could go wrong are:

  • ‘leaderstats’ might not be a child of the player, resulting in an eternal WaitForChild call
  • leaderstats.Strength is not more or equal to 0

Also, we might need a bit more context to help you out. What does the output say? Have you tried to call print(someString) to check where your code fails?

1 Like

Check if a folder for leaderstats is already created
If not your script won’t work if it can’t find it

Can be fixed by adding

local leaderstats = instance.new(Folder)
   leaderstats.Name = "leaderstats" 
leaderstats.Parent = player

Without such code your script is waiting for a child that doesn’t exist

Thanks for the help i found the error I didn’t have to put ‘=’ sign in line 11 " if selling.Value > 0 then"