RemoteEvent fires but does nothing

Hello! I’m working on a boss fight for my game. I’m using a remote event to trigger the fight, and it is firing, but not doing anything when being fired.

The remote event is being fired from the server.

This is the script that fires the event:

local PlayersService = game:GetService("Players")
local Players = PlayersService:GetPlayers()
local LocalPlayer = PlayersService.PlayerAdded:Wait()

local RunService = game:GetService("RunService")
local VerdenaPrime = game.Workspace.VerdenaPrime
local Active = VerdenaPrime:WaitForChild("Values").Active
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Triggers = game.Workspace.Triggers
local FightTrigger = Triggers.VerdenaFightTrigger

local StartFightRemote = ReplicatedStorage:WaitForChild("Remotes").StartFight

FightTrigger.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		StartFightRemote:FireClient(LocalPlayer)
		print("Fired")
	end
end)

And this is the script that recieves it:

local PlayersService = game:GetService("Players")
local ListOfPlayers = PlayersService:GetPlayers()

local VerdenaPrime = game.Workspace.VerdenaPrime
local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PathfindingService = game:GetService("PathfindingService")

local Modules = ReplicatedStorage:WaitForChild("Modules")
local remotes = ReplicatedStorage:WaitForChild("Remotes")
local StartFightRemote = remotes.StartFight

local UI = VerdenaPrime:WaitForChild("Head").UI
local SecondUI = VerdenaPrime.Head.SecondUI

local Active = VerdenaPrime:WaitForChild("Values").Active

local Attachment0 = VerdenaPrime.HumanoidRootPart.RootAttachment
local Attachment1 = player.Character:WaitForChild("HumanoidRootPart").RootAttachment

-- Requiring Modules

local AttacksList = require(script.Attacks)
local Dialogue = require(Modules.Dialogue)
local HitboxCreator = require(Modules.HitboxCreator)
local UIHandler = require(Modules.UIHandler)

StartFightRemote.OnClientEvent:Connect(function()
	print("Starting fight")
	
	-- Dialogue
	
	Dialogue.ShowDialogue("", "The ground shifts beneath you.", player, 2, 2, Color3.fromRGB(255, 255, 255))
	wait(4)
	Dialogue.ShowDialogue("VERDENA PRIME", "Hello, Amber. I've been expecting you.", player, 3.5, 2, Color3.fromRGB(255, 255, 255))
	wait(4)
	Dialogue.ShowDialogue("VERDENA PRIME", "We all have been, actually.", player, 3, 2, Color3.fromRGB(255, 255, 255))
	wait(4)
	Dialogue.ShowDialogue("VERDENA PRIME", "And we've prepared. Everyone you threaten has hidden elsewhere.", player, 4, 2, Color3.fromRGB(255, 255, 255))
	wait(5)
	Dialogue.ShowDialogue("VERDENA PRIME", "Leaving a hollow shell of what this place once was.", player, 3, 2, Color3.fromRGB(255, 255, 255))
	wait(4)
	Dialogue.ShowDialogue("VERDENA PRIME", "A shell that I must protect.", player, 2, 2, Color3.fromRGB(255, 255, 255))
	wait(3)
	Dialogue.ShowDialogue("VERDENA PRIME", "And one that I will.", player, 2, 2, Color3.fromRGB(255, 255, 255))
	wait(4)
	Dialogue.ShowDialogue("VERDENA PRIME", "Even if it costs me my life.", player, 2, 2, Color3.fromRGB(255, 60, 60))
	
	Active.Value = true
	HitboxCreator.CreateBossHitbox(VerdenaPrime, Vector3.new(4.25, 6, 5))
	UIHandler.SpawnBossHealthBar("VERDENA /// PRIME")
end)

This is a video of the bug happening, including the output. You can see that the output prints “Fired” which is in the server script that fires the event, after it’s been fired. However it doesn’t print “Starting fight” which should be printed when the event starts.

1 Like

Let’s try debugging the code. My first idea is to add a line of code to the provided local script. At the end of this script add the following line:
print("I'm fully loaded!")
After that, play the game again and check if you can see “I’m fully loaded!” text in the output.

1 Like

It didn’t print in output, however there are also no errors in the output.

1 Like

Okay, we know something from that. We know that the local script stops somewhere above the code reponsible for receiving a remote event signal, the script is disabled or the script is in a incorrect place. To check the last possible scenario, please show where the local script is located in the Explorer.

2 Likes

I tried putting a print statement above the remote event part, and it didn’t print, however when placing it above the lines that require the modules, it does. So it’s probably an issue with one of the module scripts.

Both scripts are enabled, the server script that fires the event is in ServerScriptService.

Here’s the image of the script in the explorer (VerdenaTest is the script, the other local script has nothing to do with it.)
location

1 Like

This is a part of the local script:

-- Requiring Modules

local AttacksList = require(script.Attacks)
local Dialogue = require(Modules.Dialogue)
local HitboxCreator = require(Modules.HitboxCreator)
local UIHandler = require(Modules.UIHandler)

Replace the part with this:

-- Requiring Modules

print(1)
local AttacksList = require(script.Attacks)
print(2)
local Dialogue = require(Modules.Dialogue)
print(3)
local HitboxCreator = require(Modules.HitboxCreator)
print(4)
local UIHandler = require(Modules.UIHandler)
print(5)

After that, run the game and see what numbers will be printed.

1 Like

I tried removing each module variable from the script (also editing the script so it wouldn’t cause errors from the removed variables), None of them fixed anything but if I remove all of them at once it prints the statement at the end of the script.

2 Likes

It’s stopping on 1.

I also changed them to Modules:WaitForChild incase they weren’t able to load, which didn’t change anything.

I messed around a little bit and it seems that AttacksList and HitboxCreator both stop the script where it is.

2 Likes

local AttacksList = require(script:WaitForChild("Attacks"))
I assume that you also did that. Maybe something is running forever in the module itself?

I think that’s exactly the issue, the AttacksList module script also requires some of the other module scripts, which is causing them to never be able to fully load, since they endlessly require eachother.
I tried removing the require lines from AttacksList and now it gets past it in the local script.

I don’t understand whats going on with HitboxCreator though, as it doesn’t require any other modules.

Quick question, are you able to get the local player from a module script? That’s the only line that I can think of that can be causing the issue in HitboxCreator.

These are the lines I’m talking about:

local players = game.Players
local LocalPlayer = players.PlayerAdded:Wait()

If you cannot figure out what is going on with HitboxCreator, maybe I can take a look at it? I suspect that you can sort out other modules to eliminate the issue.

That was it! I assume you can’t get LocalPlayer in module scripts, since removing that from the script fixed it and the event is firing now.

Looking back I don’t even know why I tried getting the player. There isn’t a single spot in the module that needs the local player.

2 Likes

Good to know that the system works as intented after doing all of that. Really nice!

1 Like

Actually, turns out AttacksList was fine, it was only breaking because HitboxCreator couldn’t load correctly since I tried to get the player there.

1 Like

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