Keep getting errors when the script was written right!

Over the last week I have been watching YouTube videos from @M_nzter youtube series for his clicker game.

however on this video
How to Create an Auto Clicker in Roblox! How to Make a Simulator in Roblox Episode 5 - YouTube, i keep getting errors

The error

PlayerGui.ClickButtons.Manager:37: attempt to index nil with ‘BackgroundColor3’

The Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage.Remotes

local Gui = script.Parent
local Frame = Gui.Frame

local Click = Frame.Click
local FastAuto = Frame.Fast
local RegularAuto = Frame.Regular

local BUTTON_OFF_COLOUR = Color3.fromRGB(255, 93, 93)
local BUTTON_ON_COLOUR = Color3.fromRGB(142, 255, 94)

local STROKE_OFF_COLOUR = Color3.fromRGB(149, 54, 54)
local STROKE_ON_COLOUR = Color3.fromRGB(95, 171, 63)
local CLICK_TEXT_TEMPLATE = "TYPE Auto Clicker (MODE)"

local RegularMode = false
local FastMode = false

local function UpdateButton(buttonType: "Regular" | "Fast", mode: boolean)
	local button = nil
	if buttonType == "Regular" then
		button = RegularAuto
		RegularMode = mode
	else
		buttonType = FastAuto
		FastMode = mode
	end
	
	if mode then
		button.BackgroundColor3 = BUTTON_ON_COLOUR
		button.label.Text = CLICK_TEXT_TEMPLATE:gsub("TYPE", buttonType):gsub("MODE", "On")
		button.label.TextColor3 = BUTTON_ON_COLOUR
		button.UIStroke.Color = STROKE_ON_COLOUR
	else
		button.BackgroundColor3 = BUTTON_OFF_COLOUR
		button.label.Text = CLICK_TEXT_TEMPLATE:gsub("TYPE", buttonType):gsub("MODE", "Off")
		button.label.TextColor3 = BUTTON_OFF_COLOUR
		button.UIStroke.Color = STROKE_OFF_COLOUR
	end
	
end

FastAuto.MouseButton1Click:Connect(function()
	Remotes.UpdateAutoClicker:FireServer("Fast")
end)

RegularAuto.MouseButton1Click:Connect(function()
	Remotes.UpdateAutoClicker:FireServer("Regular")
end)

Click.MouseButton1Click:Connect(function()
	Remotes.Click:FireServer()
end)

Remotes.UpdateAutoClicker.OnClientEvent:Connect(UpdateButton)
UpdateButton("Regular", Remotes.GetAutoClickMode:InvokeServer("Regular"))
UpdateButton("Fast", Remotes.GetAutoClickMode:InvokeServer("Fast"))

Can anyone help me with the error?

button is not getting set to anything. Probably because of this line:

buttonType = FastAuto --Should be button not buttonType?

Good spot thank you. It worked

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