Local script not loading modules in game

For some reason, the local script won’t run the module script loading code, or anything after it.

Code that loads the module scripts:

-- vfx modules
local vfxmodules = game:GetService("ReplicatedStorage").VFXMODULES
local DragonSlayerSlamModule = require(vfxmodules:WaitForChild("DragonSlayerSlam")) -- doesn't load this line or anything after it
local DragonSlayerSlashModule = require(vfxmodules:WaitForChild("DragonSlayerSlash"))
local RockSpawnModule = require(vfxmodules:WaitForChild("RockSpawner"))

After rearranging the code, it still stops when it tries to load the module scripts, so it’s probably an issue with those.
image

No visible errors in the output. Also, works in studio just fine, but when loading into the published game, it breaks. If you guys need more information, I’m more than willing to post it to solve this issue.
Any help would be appreciated.

Send the contents of the “DragonSlayerSlam” module.

1 Like
local module = {}
local player = game.Players.LocalPlayer

local SLAMROCKSIZE = Vector3.new(4,4,4) -- size of the rocks that spawn around in cricle when the ground is hit

-- particle effect and character stuff
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DragonSlayerVFXFolder = ReplicatedStorage.VFX.DragonSlayerStuff
local DragonSlayerEffects = DragonSlayerVFXFolder.DragonSlayerClientEffects
local PhysicsService = game:GetService("PhysicsService")
game.Players.LocalPlayer.CharacterAdded:Wait() -- waiting for character to load in
local character = game.Players.LocalPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local dbservice = game:GetService("Debris")
local rockspawnmodule = require(ReplicatedStorage.VFXMODULES:WaitForChild("RockSpawner"))
local rockposfunction = ReplicatedStorage.VFX:WaitForChild("RockLocation")
local tagremover = ReplicatedStorage.GeneralRemotes:WaitForChild("FindTag")

-- Tweens, sound effects, animations and Debounce (FIX THE DEBOUCE)
local hiteffect = DragonSlayerEffects:WaitForChild("dragon slayer hit effect")
local hitsoundeffect = script["dragon slayer hit"]:Clone()
local tweenservice = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(2.5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,5)

-- Player related variables

local pservice = game:GetService("Players")
local plr = pservice.LocalPlayer
local mouse = plr:GetMouse()
local uis = game:GetService("UserInputService")

function module.RockSpawn(pos)
	local Variables = rockposfunction:InvokeServer()
	rockspawnmodule.onerock(nil,true, Variables, pos, SLAMROCKSIZE)
end

function module.spawneffect(pos, blade)
	local clone = hiteffect:Clone()
	clone.Parent = workspace
	clone.Position = pos.Position - Vector3.new(0,3,0)
	hitsoundeffect.Parent = blade
	hitsoundeffect:play()

	for _, emitter in ipairs(clone:GetDescendants()) do
		if emitter:IsA("ParticleEmitter") then
			if emitter.Name == "Sparks" then
				emitter.Enabled = true
				task.spawn(function()
					task.wait(1)
					emitter.Enabled = false
				end)
			elseif emitter.Name == "Smoke" then
				emitter.Enabled = true
				task.spawn(function()
					task.wait(1)
					emitter.Enabled = false
				end)
			elseif emitter.Name == "Ground Radial Effect" then
				emitter.Enabled = true
				task.spawn(function()
					task.wait()
					emitter.Enabled = false
				end)
			elseif emitter.Name == "Wave1" then
				emitter.Enabled = true
				task.spawn(function()
					task.wait(1)
					emitter.Enabled = false
				end)
			elseif emitter.Name == "Wave2" then
				emitter.Enabled = true
				task.spawn(function()
					task.wait(1)
					emitter.Enabled = false
				end)
			end
		end
	end
	return clone
end


function module.M1SlamAttack(HMRP, rocktable, blade)
	task.wait(1.35) -- compensating for animation time
	local hrp = humanoid.Parent:FindFirstChild("HumanoidRootPart")
	local pos = HMRP.CFrame * CFrame.new(1,1,-13)
	local effect_clone = module.spawneffect(pos, blade)
	module.RockSpawn(pos, rocktable)
	tagremover:InvokeServer("Remove", "Attacking")
	task.wait(4) -- waiting for the paritcle emitters in effect to completely dissapear
	effect_clone:Destroy()
end

return module

This, is your script in StarterCharacterScripts? If so, It is guaranteed the character will exist the script will be in the character itself, you can just use script.Parent to get the character, but not in the module, for that you would have to use player.Character.

3 Likes

If that’s the case, why does it work in Studio but not the actual game?

Assuming your script is in there, this usually occur due to studio being a bit more laggy then the real game. Things load slower in studio.; but that’s probably not the reason. Try what I said and see if it works.

1 Like

it actually worked, thank you so much

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