This is the fraction of the code in the script that causes the issue
print("GettingSelfModule")
local EncounterInfo = require(Region.EncounterInfo)
print("ModulesChecked")
Self is the argument to a function, it is passed correctly and no errors happen, the script just yields forever, it is worth noting that this cript is a local script and the modulescript is a descendant workspace.
It’s trying to find something that doesn’t exist, because I’m assuming Self isn’t workspace. This leaves it to infinitely yield, as it’ll infinitely search.
On a side not, I find it rather confusing that you’re naming a variable Self, unless you’re using it for some sort of OOP work, as then you’ve got Self and self and it’s just bad naming practice.
The only issue I might be able to assume is that the module isn’t returning anything? Other than that I wouldn’t be able to say without looking at the script itself
local db = false
if not game:IsLoaded() then
game.Loaded:Wait()
end
local cs = game:GetService("CollectionService")
local EncounterParts = cs:GetTagged("EncounterRegion")
local function TriggerEncounter(Part , Region)
if db == false then
db = true
Region.CanTouch = false
if math.random(1,20) == 1 then
print("Region")
local LocalParty = require(game.ReplicatedStorage.Cache)
print("GettingRegionModule")
local EncounterInfo = require(Region.EncounterInfo)
print("ModulesChecked")
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
wait(0.1)
local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Disable()
wait(0.3)
game.TweenService:Create(workspace.CurrentCamera , TweenInfo.new(0.4) , {FieldOfView = 90}):Play()
wait(0.4)
game.TweenService:Create(workspace.CurrentCamera , TweenInfo.new(0.4) , {FieldOfView = 30}):Play()
game.TweenService:Create(game.Players.LocalPlayer.PlayerGui.BattleScreen.BlackScreen , TweenInfo.new(0.3) , {BackgroundTransparency = 0}):Play()
wait(0.4)
local MaxChance = 0
for i , v in pairs(EncounterInfo) do
MaxChance += v.Chance
end
local EnemyCreature
while true do
for i , v in pairs(EncounterInfo) do
if math.random(1,MaxChance) <= v.Chance then
EnemyCreature = v.Creature
end
end
end
local Encounter = game.ReplicatedStorage.RefreshGui:InvokeServer(EnemyCreature , LocalParty[game.Players.LocalPlayer.UserId][1])
print(EnemyCreature , LocalParty[1])
workspace.CurrentCamera.FieldOfView = 90
game.TweenService:Create(game.Players.LocalPlayer.PlayerGui.BattleScreen.BlackScreen , TweenInfo.new(0.3) , {BackgroundTransparency = 1}):Play()
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
game.Players.LocalPlayer.Character.HumanoidRootPart.Anchored = false
wait(0.3)
end
wait(0.1)
Region.CanTouch = true
db = false
end
end
for i , v in pairs(EncounterParts) do
v.Touched:Connect(function(Part)
TriggerEncounter(Part , v)
end)
end
I assume there’s a module in every single part which is within the EncounterParts, so I think the only issue I can see if the script works fine without that one line is the require within the module itself, possibly the Creature variable is never loading? Try doing game:GetService(“ReplicatedStorage”) and see if that fixes anything.