Script not working (Solved)

local PurchaseCarEvent = game.ReplicatedStorage:WaitForChild("PurchaseCar")
local PaintCarModule = require(game.ReplicatedStorage:WaitForChild("PaintCarModule"))
local GetCarColor = PaintCarModule.GetCarColor
local PaintCar = PaintCarModule.PaintCar
local BuyButton = script.Parent.BuyButton
local BackButton = script.Parent.BackButton
local PaintButton = script.Parent.PaintButton
local ColorDialog = require(game.ReplicatedStorage:WaitForChild("ColorDialogModule")).CreateDialog(script.Parent.Parent)
local Event = script.Parent.Parent.ShowPurchaseFrame
local ColorChangedEvent = script.Parent.Parent.ColorChanged
local Color = ColorDialog.Color
local Callback_paint = nil
local Callback_back = nil
local Callback_buy = nil
local Callback_color = nil

Event.Event:Connect(function(Name, Cost, Power, CarImage)
	local ChangedColor = nil
	script.Parent.Parent.PurchaseFailedTitle.Visible = false
	script.Parent.Visible = true
	script.Parent.CarName.Text = Name
	script.Parent.Power.Text = Power .. " hp"
	script.Parent.Cost.Text = Cost
	local curCarImage = script.Parent:FindFirstChild("CarImage")
	if curCarImage then
		curCarImage:Remove()
	end
	local clonedCarImage = CarImage:Clone()
	clonedCarImage.Parent = script.Parent
	clonedCarImage.Position = UDim2.new(0, 0, 0, 0)
	clonedCarImage.Size = UDim2.new(0.8, 0, 1, 0)
	clonedCarImage.Name = "CarImage"
	local Car = clonedCarImage:FindFirstChildWhichIsA("Model")
	local StartColor = GetCarColor(Car)
	if Callback_back then
		Callback_back:disconnect()
		Callback_back = nil
	end
	Callback_back = BackButton.MouseButton1Down:Connect(function()
		script.Parent.Visible = false
		ColorDialog.Visible = false
	end)
	if Callback_buy then
		Callback_buy:disconnect()
		Callback_buy = nil
	end
	Callback_buy = BuyButton.MouseButton1Down:Connect(function()
		if not ColorDialog.Visible then
			local ShopCarName = CarImage.Parent.Name
			PurchaseCarEvent:FireServer(ShopCarName, ChangedColor)
			script.Parent.Visible = false
			ColorDialog.Visible = false
		end
	end)
	if Callback_paint then
		Callback_paint:disconnect()
		Callback_paint = nil
	end
	Callback_paint = PaintButton.MouseButton1Down:Connect(function()
		ColorDialog.Visible = true
		if Callback_color then
			Callback_color:disconnect()
			Callback_color = nil
		end
		Callback_color = ColorChangedEvent.Event:Connect(function(accept)
			if accept == nil then
				PaintCar(Car, Color.Value)
			elseif accept == true then
				ColorDialog.Visible = false
				if StartColor then
					local color = GetCarColor(Car)
					StartColor = color
					ChangedColor = color
				end
			elseif accept == false then
				ColorDialog.Visible = false
				if StartColor then
					PaintCar(Car, StartColor)
				end
			end
		end)
	end)
end)

so basically im making a car dealership all was working till i wanted to make it so it can paint a car, but it all of a sudden doesn’t work, when i click on a car the gui doesn’t pop up and this error comes up

2 Likes

Where is PurchaseFailedTitle located within the explorer? (Provide an image please)

image
it is in startergui

1 Like

Your spelling is mistaken. In the script, it’s “PurchaseFailedTitle” but the object name is “PurchasedFailedTitle”.

ima see if it works in about 7 hours, cuz i got school now

Not really enough to help you here without mock rebuilding all that.
Save your program like name_01 name_02, and you can go back to get your old working anything quickly. Back up scripts before you work on them …

You can also probably get an old version restore.

I do agree with you here, organizing and saving versions of your script is key to debugging faster. However, his problem is just simple spelling mistakes like we all do.

Sweet … But I’m not even looking unless I see enough to work with. GJ!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.