How do I fix this bug?

How do I fix this bug?

local PartToDisplay = script.Parent

local ProximityPrompt = script.Parent.ProximityPrompt

local ChatService = game:GetService("Chat")

local Debouce = false

local Settings = {

DebouceTime = 5,

Message = "hello, i am rock.",

Message2 = "welcome to rock town.",

Message3 = "go talk to nerd rock.",

Message4 = "continue the storyline",

ColorOfText = Enum.ChatColor.White

}


ProximityPrompt.Triggered:Connect(function(Player)
	if Debouce == false then
		if Player.MetRock == false and Player.TalkedToNerd == false then
		Debouce = true
		ProximityPrompt.Enabled = false
		wait(.15)
		ChatService:Chat(PartToDisplay,Settings.Message, Settings.ColorOfText)
		script.Parent.Hello:Play()
		local F = talking()
		task.wait(Settings.DebouceTime)
		F()
		ChatService:Chat(PartToDisplay,Settings.Message2, Settings.ColorOfText)
		script.Parent.Welcome:Play()
		local F = talking()
		task.wait(Settings.DebouceTime)
		F()
		ChatService:Chat(PartToDisplay,Settings.Message3, Settings.ColorOfText)
		script.Parent.TalkTo:Play()
		local F = talking()
		task.wait(3)
		F()
		wait(13)
		Player.MetRock = true
		ProximityPrompt.Enabled = true
			Debouce = false
		end
	elseif Player.MetRock == true and Player.TalkedToNerd == false then
			Debouce = true
			ProximityPrompt.Enabled = false
			wait(.15)
			ChatService:Chat(PartToDisplay,Settings.Message3, Settings.ColorOfText)
			script.Parent.TalkTo:Play()
			local F = talking()
			task.wait(Settings.DebouceTime)
			F()
			ProximityPrompt.Enabled = true
			Debouce = false
	end
	elseif Player.MetRock == true and Player.TalkedToNerd == true then
	Debouce = true
	ProximityPrompt.Enabled = false
	wait(.15)
	ChatService:Chat(PartToDisplay,Settings.Message4, Settings.ColorOfText)
	script.Parent.TalkTo:Play()
	local F = talking()
	task.wait(Settings.DebouceTime)
	F()
	ProximityPrompt.Enabled = true
	Debouce = false
	end
end)

the bug:

You forgot to put an end to this if:

if Player.MetRock == false and Player.TalkedToNerd == false then

what line would I put the end in?
because there is already an end to that if
the bug is the 3rd else if.

You accidentally put the elseif outside of the original if statement. Here’s the fixed script. Also, wait is deprecated. It’s recommended using task.wait now. I switched all waits for task.wait in your code.

local PartToDisplay = script.Parent

local ProximityPrompt = script.Parent.ProximityPrompt

local ChatService = game:GetService("Chat")

local Debouce = false

local Settings = {

	DebouceTime = 5,

	Message = "hello, i am rock.",

	Message2 = "welcome to rock town.",

	Message3 = "go talk to nerd rock.",

	Message4 = "continue the storyline",

	ColorOfText = Enum.ChatColor.White

}


ProximityPrompt.Triggered:Connect(function(Player)
	if Debouce == false then
		if Player.MetRock == false and Player.TalkedToNerd == false then
			Debouce = true
			ProximityPrompt.Enabled = false
			task.wait(.15)
			ChatService:Chat(PartToDisplay,Settings.Message, Settings.ColorOfText)
			script.Parent.Hello:Play()
			local F = talking()
			task.wait(Settings.DebouceTime)
			F()
			ChatService:Chat(PartToDisplay,Settings.Message2, Settings.ColorOfText)
			script.Parent.Welcome:Play()
			local F = talking()
			task.wait(Settings.DebouceTime)
			F()
			ChatService:Chat(PartToDisplay,Settings.Message3, Settings.ColorOfText)
			script.Parent.TalkTo:Play()
			local F = talking()
			task.wait(3)
			F()
			task.wait(13)
			Player.MetRock = true
			ProximityPrompt.Enabled = true
			Debouce = false
		end
	elseif Player.MetRock == true and Player.TalkedToNerd == false then
		Debouce = true
		ProximityPrompt.Enabled = false
		task.wait(.15)
		ChatService:Chat(PartToDisplay,Settings.Message3, Settings.ColorOfText)
		script.Parent.TalkTo:Play()
		local F = talking()
		task.wait(Settings.DebouceTime)
		F()
		ProximityPrompt.Enabled = true
		Debouce = false
	elseif Player.MetRock == true and Player.TalkedToNerd == true then
		Debouce = true
		ProximityPrompt.Enabled = false
		task.wait(.15)
		ChatService:Chat(PartToDisplay,Settings.Message4, Settings.ColorOfText)
		script.Parent.TalkTo:Play()
		local F = talking()
		task.wait(Settings.DebouceTime)
		F()
		ProximityPrompt.Enabled = true
		Debouce = false
	end
end)
2 Likes