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

How do I sell a "tool" in my starter pack?

Asked by
ThatHertz -10
6 years ago
Edited 6 years ago

So I'm working on something but it's not working. I'm trying to sell a "tool" thats in the starter pack. Here is the script:

  1. local debounce = false

  2. function getPlayer(humanoid)

  3. local players = game.Players:children()

  4. for i = 1, #players do

  5. if players[i].Character.Humanoid == humanoid then return players[i] end

  6. end

  7. return nil

  8. end

  9. function onTouch(part)

  10. local human = part.Parent:findFirstChild("Humanoid")

  11. if (human ~= nil) and debounce == false then

  12. debounce = true

  13. local player = getPlayer(human)

  14. if (player == nil) then return end

  15. user = game.Players:findFirstChild(human.Parent.Name)

  16. local gold = user.leaderstats.Gold

    1. if player.StarterGear:findFirstChild(script.Parent.Parent.SETTINGS.Item.Value) ~= nil 18. then

    2. gold.Value = gold.Value + script.Parent.Parent.SETTINGS.SellbackPrice.Value

    3. m = Instance.new("Hint")

    4. m.Text = "You sold " ..script.Parent.Parent.SETTINGS.Item.Value.. " for " 22. ..script.Parent.Parent.SETTINGS.SellbackPrice.Value.. " gold!" -- message

    5. m.Parent = player.PlayerGui

    6. player.Backpack:findFirstChild(script.Parent.Parent.SETTINGS.Item.Value):remove()

    7. player.StarterGear:findFirstChild(script.Parent.Parent.SETTINGS.Item.Value):remove()

    8. wait(2)

    9. m.Parent = nil

  17. else

    1. m = Instance.new("Hint")

    2. m.Text = "You need the " ..script.Parent.Parent.SETTINGS.Item.Value.. " to do this."

    3. m.Parent = player.PlayerGui

    4. wait(3)

    5. m.Parent = nil

  18. end

  19. wait(2)

  20. debounce = false

  21. end

  22. end

  23. script.Parent.Touched:connect(onTouch)

I already have the SETTINGS and let's say the object I'm trying sell is called "Apple".

FYI this is not for a Gamepass or a DEV Product!!! Iy may also be notable that you get the item from a "giver".

0
can you edit this so it is completely a script??? this is difficult to see, sorry xD User#20388 0 — 6y
0
I fixed it. You should now be able to read it better. ThatHertz -10 — 6y

Answer this question