Local Script randomly stops when requiring modules

I’ve been using my Local script for a while until it just stopped working, after some printing and debugging I found that where the script stops is when it attempts to require two module scripts. These scripts exists and there are no errors at all anywhere.
Portion Local Script

local PrompService = game:GetService("ProximityPromptService")
local ChatService = game:GetService("Chat")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

local ReplicatedStorage = game:GetService("ReplicatedStorage")
wait()
print("Code Running Smooth past line 9.")
local jokeAbility = require(game.ReplicatedStorage:WaitForChild("JokeAbilities"))

local quests = require(game.ReplicatedStorage:WaitForChild("Quests"))
print("Code Running Smooth past line 11.")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

local stages = workspace.Map.Stages:GetChildren()

local minx = math.random()


local npc = game.ReplicatedStorage.Clonable.Npc

local camera = game.Workspace.CurrentCamera

The script seems to stop around lines 9 - 12. On line 8 I have a print statement, that runs, but anything after that point does not.
image

image

Both Modules:
JokeAbilities

local module = {}

local player = game.Players.LocalPlayer

local rs = game.ReplicatedStorage
local events = rs.RemoteEvents

function module.BasicJoke()
	local laughs = script.Parent.Jokes.BasicJoke.Laughs.Value
	local fans = script.Parent.Jokes.BasicJoke.Fans.Value
	local joke = script.Parent.Jokes.BasicJoke
	
	events.AddValue:FireServer("Laughs", laughs, "leaderstats")
	events.AddValue:FireServer("Fans", 1, "leaderstats")
end


return module

Quests

local module = {}

local player = game.Players.LocalPlayer
local char = player.CharacterAdded:Wait() or player.Character


--Tell Jokes At Farm Quest
function module.TellJokesAtFarm(gui, folder,isAccepting,canClone)
	--Checks if we are accepting the quest and if it is not already finished.
	
	local laughsReward = 25
	local fansReward = 2
	
	if isAccepting and folder.Completed.Value == 0 then
		--Clones GUI and sets up how it looks
		local quest = gui:Clone()
		quest.Parent = player.PlayerGui.ScreenGui.Quests.Quests
		quest.Name = "TellJokesAtFarm"
		quest.Title.Text = "Tell Jokes At Farm"
		quest.Status.Text = tostring(folder.Told.Value) .. "/" .. tostring(folder.Max.Value)
		--Changes accepted variable to 1 (meaning true for us)
		game.ReplicatedStorage.RemoteEvents.EditQuest:FireServer("Accepted", 1, "Quests", "TellJokesAtFarm")
	end
	--Checks if we have accepted the quest
	if folder.Accepted.Value == 1 and folder.Completed.Value == 0 then
		--Adds value to the quest folder in our player and updates UI
		local quest = player.PlayerGui.ScreenGui.Quests.Quests.TellJokesAtFarm
		folder.Told.Value += 1
		quest.Title.Text = "Tell Jokes At Farm"
		quest.Status.Text = tostring(folder.Told.Value) .. "/" .. tostring(folder.Max.Value)
		if folder.Told.Value >= folder.Max.Value then
			--Edits Completed Quest Value to 1 (true for us)
			game.ReplicatedStorage.RemoteEvents.EditQuest:FireServer("Completed", 1, "Quests", "TellJokesAtFarm")
			--Destroys the UI
			quest:Destroy()
			
			local root = char.HumanoidRootPart --Get humanoid root part
			local a0 = root:WaitForChild("RootRigAttachment")
			game.ReplicatedStorage.RemoteEvents.Guide.SetPathLocally:FireServer(a0, workspace.Map.Guide.Joe)
			
			
			--Notifications and Reward
			game.ReplicatedStorage.RemoteEvents.LocallyNotify:FireServer("Tell Jokes At Farm Quest Completed!", 3)
			wait()
			game.ReplicatedStorage.RemoteEvents.LocallyNotify:FireServer("+"..laughsReward .." Laughs", 3)
		end
	end
end

	
	


return module


Edit Did some more debugging, seems to be specifically not requiring the Quests module.

Since it is not requiring the Quests module, maybe that is because the module is still waiting for the player’s character to be added. Inside of the Quests module, replace, “local char = player.CharacterAdded:Wait() or player.Character,” with, “local char = player.Character or player.CharacterAdded:Wait().”

1 Like

Haha, Just caught myself while looking through the Quests module right now and just noticed it! Thank you though, much appreciated.

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