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

What is wrong in this script?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
model = script.Parent.Parent.Parent.CarSeat.Value.Parent.Parent

function onclick ()
    sell = script.Parent.Parent.Parent.sell.Value
    local stats = game.Players.LocalPlayer:FindFirstChild("leaderstats")
    if stats ~= nil then
        local cash = stats:FindFirstChild("Money")
        cash.Value = cash.Value + sell
        script.Parent.Parent.Parent:Destroy()
        script.Parent.Parent.Parent.Parent.Parent.Parent:remove()
    end

end

script.Parent.MouseButton1Click:connect(onclick)

it says: 00:01:16.443 - Players.Player.PlayerGui.Screen.Frame.TextButton.Script:10: attempt to index field 'Parent' (a nil value) 00:01:16.444 - Script 'Players.Player.PlayerGui.Screen.Frame.TextButton.Script', Line 10

0
What are you trying to do with this? Im_Kritz 334 — 9y
0
it is a script for selling stuff thegamingpro566 0 — 9y
0
its ok guys i figured the problem my self i fixed the problem the script works fine now thegamingpro566 0 — 9y

1 answer

Log in to vote
2
Answered by
Chronomad 180
9 years ago

Well, it looks like you already removed the script on line 9

script.Parent.Parent.Parent:Destroy()

So instead, I'd remove line 9 entirely, and change line 10 to say,

script.Parent.Parent.Parent.Parent.Parent.Parent:Destroy() -- remove is old school

Hope this helps! Let me know if it did.

0
i figured it out but i changed some other stuff on the script aswell as that there was something wrong with some things at the top i had to add some stuff to it thegamingpro566 0 — 9y
Ad

Answer this question