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

What is wrong in this script?

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

3 comments

0

What are you trying to do with this?

0

it is a script for selling stuff

0

its ok guys i figured the problem my self i fixed the problem the script works fine now

1 answer

✓ Accepted answer

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.

1 comment

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

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