Hello! I am working on a game, and I noticed that the game wont work, most likely because of this issue: I open the output and I noticed this:
Why does it say requested module experienced an error while loading?
By the way, here is the code for the module that “experienced an error”:
-- [[ Constants ]]--
local ZERO_VECTOR3 = Vector3.new(0, 0, 0)
local STATE_JUMPING = Enum.HumanoidStateType.Jumping
local STATE_FREEFALL = Enum.HumanoidStateType.Freefall
local STATE_LANDED = Enum.HumanoidStateType.Landed
--[[ Local Variables ]]--
local MasterControl = {}
local Players = game:GetService('Players')
local RunService = game:GetService('RunService')
local RunningShoes, Hoverboard, Utilities
--local _p = require(game:GetService('ReplicatedStorage').Plugins)
--local Utilities = require(game:GetService('ReplicatedStorage').Utilities)
while not Players.LocalPlayer do wait() end
local LocalPlayer = Players.LocalPlayer
local CachedHumanoid = nil
local RenderSteppedCon = nil
local SeatedCn = nil
local moveFunc = LocalPlayer.Move
local defaultMoveFunc = moveFunc
local isJumping = false
local areControlsEnabled = true
local isSeated = false
local myVehicleSeat = nil
local moveValue = Vector3.new(0,0,0)
local zero3 = Vector3.new()
MasterControl.WalkEnabled = true
MasterControl.JumpEnabled = false
MasterControl.IsIndoors = false
local function signal()
local sig = {}
local mSignaler = Instance.new('BindableEvent')
local mArgData = nil
local mArgDataCount = nil
function sig:fire(...)
mArgData = {...}
mArgDataCount = select('#', ...)
mSignaler:Fire()
end
function sig:connect(f)
if not f then error('connect(nil)', 2) end
return mSignaler.Event:connect(function()
f(unpack(mArgData, 1, mArgDataCount))
end)
end
function sig:wait()
mSignaler.Event:wait()
assert(mArgData, 'Missing arg data, likely due to :TweenSize/Position corrupting threadrefs.')
return unpack(mArgData, 1, mArgDataCount)
end
return sig
end
MasterControl.Changed = signal()
local clickToMoveFailStateChanged = Instance.new("BindableEvent")
clickToMoveFailStateChanged.Name = "ClickToMoveFailStateChanged"
--[[ Local Functions ]]--
function MasterControl:GetHumanoid()
if LocalCharacter then
if CachedHumanoid then
return CachedHumanoid
else
CachedHumanoid = LocalCharacter:FindFirstChildOfClass("Humanoid")
return CachedHumanoid
end
end
end
local characterAncestryChangedConn = nil
local characterChildRemovedConn = nil
local function characterAdded(character)
if characterAncestryChangedConn then
characterAncestryChangedConn:disconnect()
end
if characterChildRemovedConn then
characterChildRemovedConn:disconnect()
end
LocalCharacter = character
CachedHumanoid = LocalCharacter:FindFirstChildOfClass("Humanoid")
characterAncestryChangedConn = character.AncestryChanged:connect(function()
if character.Parent == nil then
LocalCharacter = nil
else
LocalCharacter = character
end
end)
characterChildRemovedConn = character.ChildRemoved:connect(function(child)
if child == CachedHumanoid then
CachedHumanoid = nil
end
end)
end
if LocalCharacter then
characterAdded(LocalCharacter)
end
LocalPlayer.CharacterAdded:connect(characterAdded)
local getHumanoid = MasterControl.GetHumanoid
local moveFunc = LocalPlayer.Move
local updateMovement = function()
--
--if not areControlsEnabled then return end
--
--local humanoid = getHumanoid()
--if not humanoid then return end
--
--if isJumpEnabled and isJumping and not humanoid.PlatformStand then
-- local state = humanoid:GetState()
-- if state ~= STATE_JUMPING and state ~= STATE_FREEFALL and state ~= STATE_LANDED then
-- humanoid.Jump = isJumping
-- end
--end
--
--moveFunc(LocalPlayer, moveValue, true)
end
function MasterControl:InstallPlugins(r, h, u)--p)
RunningShoes = r--p.RunningShoes
Hoverboard = h
Utilities = u--p.Utilities
end
--[[ Public API ]]--
function MasterControl:Init()
if self.initialized then return end
self.initialized = true
local renderStepFunc = function()
if not self.WalkEnabled then return end
if LocalPlayer and LocalPlayer.Character then
local humanoid = getHumanoid()
if not humanoid then return end
if self.JumpEnabled and humanoid and not humanoid.PlatformStand and isJumping then
humanoid.Jump = isJumping
end
moveFunc(LocalPlayer, moveValue, true)
end
end
local success = pcall(function() RunService:BindToRenderStep("MasterControlStep", Enum.RenderPriority.Input.Value, renderStepFunc) end)
if not success then
if RenderSteppedCon then return end
RenderSteppedCon = RunService.RenderStepped:connect(renderStepFunc)
end
end
function MasterControl:Enable()
-- areControlsEnabled = true
-- isJumpEnabled = true
--
-- if self.ControlState.Current then
-- self.ControlState.Current:Enable()
-- end
end
function MasterControl:Disable()
local success = pcall(function() RunService:UnbindFromRenderStep("MasterControlStep") end)
if not success then
if RenderSteppedCon then
RenderSteppedCon:disconnect()
RenderSteppedCon = nil
end
end
moveValue = Vector3.new(0,0,0)
isJumping = false
end
do
local flat = Vector3.new(1, 0, 1)
local stepped = RunService.RenderStepped
function MasterControl:WalkTo(point, ws)
Hoverboard:unequip(true)
local thisThread = {}
self.walkThread = thisThread
self.WalkEnabled = false
local human = getHumanoid()
local root = human.Parent.HumanoidRootPart
local ows = human.WalkSpeed
if ws then
human.WalkSpeed = ws
end
local initialDirection = ((point-root.Position)*flat).unit
while self.walkThread == thisThread do
local direction = ((point-root.Position)*flat).unit
if math.deg(math.acos(direction:Dot(initialDirection))) > 80 then break end
moveFunc(LocalPlayer, direction, false)
stepped:wait()
end
moveFunc(LocalPlayer, zero3)
if ws then
human.WalkSpeed = ows
end
if self.walkThread == thisThread then self.walkThread = nil end
end
end
function MasterControl:Look(v, t)
Hoverboard:unequip(true)
local s, root = pcall(function() return LocalPlayer.Character.HumanoidRootPart end)
if not s or not root then return end
v = (v * Vector3.new(1, 0, 1)).unit
if t == 0 then
root.CFrame = CFrame.new(root.Position, root.Position+v)
else
local theta, lerp = Utilities.lerpCFrame(root.CFrame, CFrame.new(root.Position, root.Position+v))
if not t then
t = theta*.3
end
Utilities.Tween(t, 'easeOutCubic', function(a)
root.CFrame = lerp(a)
end)
end
end
function MasterControl:LookAt(point, t)
local s, p = pcall(function() return LocalPlayer.Character.HumanoidRootPart.Position end)
if not s or not p then return end
self:Look(point-p, t)
end
function MasterControl:Hidden(isHidden)
pcall(function() game:GetService('UserInputService').ModalEnabled = isHidden end)
pcall(function() RunningShoes:setHidden(isHidden) end)
end
function MasterControl:SetIndoors(isIndoors)
if self.IsIndoors == isIndoors then return end
self.IsIndoors = isIndoors
self.Changed:fire('IsIndoors')
end
function MasterControl:SetJumpEnabled(isJumpEnabled)
self.JumpEnabled = isJumpEnabled
getHumanoid().JumpPower = isJumpEnabled and 50 or 0
self.Changed:fire('JumpEnabled')
end
local script1 = require(script.Parent.Parent:FindFirstChild("PlayerModule"):FindFirstChild("ControlModule"))
function MasterControl:Stop()
script1:Stop()
end
function MasterControl:AddToPlayerMovement(playerMoveVector)
moveValue = Vector3.new(moveValue.X + playerMoveVector.X, moveValue.Y + playerMoveVector.Y, moveValue.Z + playerMoveVector.Z)
end
function MasterControl:GetMoveVector()
return moveValue
end
function MasterControl:SetIsJumping(jumping)
isJumping = jumping
end
function MasterControl:DoJump()
-- if not isJumpEnabled then return end
-- local humanoid = self:GetHumanoid()
-- if humanoid then
-- humanoid.Jump = true
-- end
end
function MasterControl:GetClickToMoveFailStateChanged()
return clickToMoveFailStateChanged
end
function MasterControl:SetMoveFunc(func)
local script1 = require(script.Parent.Parent.PlayerModule.ControlModule)
script1:SetMoveFunc(func)
moveFunc = func or defaultMoveFunc
end
function MasterControl:ForceJump()
local humanoid = getHumanoid()
if humanoid then
humanoid.Jump = true
end
end
return MasterControl
If you find any issues with the module please let me know!