Door = script.Parent
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouched(hit)
if debounce == false then
local human = hit.Parent:findFirstChild("Humanoid")
if (human == nil) then return end
local player = getPlayer(human)
debounce = true
if (player == nil) then return end
local stats = player:findFirstChild("leaderstats")
local sp = stats:findFirstChild("Shiny Objects")
if sp == nil then return false end
if (sp.Value >= 10) then
sp.Value = sp.Value - 10
print("Enough Money")
script.parent:remove()
end
end
end
COMMUNITY QUESTION
Why does this not work???
1 answer
Please don't just post code, make sure you include any output, etc.
However, your problem is on line 29. 'parent' should be capitalized. Therefore, script.Parent:remove()
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Do not, just DO NOT use :remove() anymore! Use :Destroy() instead.