RemoteEvent not being received server-side

I’m having a couple issues with a RemoteEvent I’ve set up not being received by the server.

It’s kind of puzzling me since I’ve done other RemoteEvents in the exact same way, but this one refuses to fire anything to the server.

As the player clicks a button, I want to fire an event which will in turn fire a module, but like I said absolutely nothing is being received from the server script:

local player = game.Players.LocalPlayer
local button = script.Parent


local UnlockAbility = function()
	local ability = button.Parent.Parent
	
	if ability:GetAttribute("SkillAttained") ~= true then
		ability:FindFirstChild("Underlay").Visible = true
		ability.ImageTransparency = 0
		ability:SetAttribute("SkillAttained",true)

		button.Text = "Unlocked"
		button.BackgroundColor3 = Color3.new(0.305882, 0.356863, 0.356863)
		button.TextColor3 = Color3.new(1, 1, 1)
		
		script.LoadAbilities:FireServer(ability)

		return ability
	else
		return "Break"
	end
end

button.MouseButton1Click:Connect(function()
	local ability = UnlockAbility()
	if ability == "Break" then return end
	
	for i,scripts in pairs (player.Backpack:GetDescendants()) do
		if scripts:IsA("LocalScript") then
			if ability:GetAttribute("Key") == scripts:GetAttribute("Key") then
				scripts.Enabled = true

			end
		end
	end
end)

There aren’t any issues with the scripts that I’m aware of, since the same code for firing the event has worked in other applications before, and I know it’s not because of the parenting of the scripts as everything is a descendant of the players PlayerGui.
Everything else in the code works fine, except the event being fired.

This is what should happen if the event is triggered by the server:

local AH = game:GetService("ReplicatedStorage"):WaitForChild("AbilityHandler")
local AbilityHandler = require(AH)

script.Parent.OnServerEvent:Connect(function(player,ability)
	print"received"
end)

Yet, I never get “received” in my output…

I’m at a loss, anybody got any ideas?

1 Like

That isnt the server script that’s the local script, you should change the name

@Yrtelvat Try commenting out the first two lines of that server script

1 Like

I’ve already tried commenting them out as well as changing the parent of the event (and therefore the server script) but the issue still persists

1 Like
  1. Is that the whole server script or is that just a snippet?
  2. Trying adding a print after where you fired the remote event in the local script
  1. Show us similiar code that works
1 Like

Thats the entire server script, nothing else has been added since it won’t do anything.

I also know the script is running since the code the change the colour of the button works, where if there was an error it would yield the LocalScript

Ex. Local:

local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local stamina = player.Backpack:WaitForChild("Stamina")
local staminaUse = 20
Enabled = true
local isTargetStunnable = false
local stunLock


uis.InputBegan:Connect(function(input,gameprocess)
	if input.KeyCode == Enum.KeyCode.V and not gameprocess then
		if not player.Character:GetAttribute("Shifted") then return end
		if stamina.Value < staminaUse then return end
		if player.Character:FindFirstChild("Action") or player.Character:FindFirstChild("Stun") then return end
		if Enabled == true then
			script.Function:FireServer("upper")
			stamina.Value = stamina.Value - staminaUse
			Enabled = false
			wait(6)
			Enabled = true
		end
	end
end)

Ex. Server:

local dmgModule = require(game:GetService("ReplicatedStorage"):WaitForChild("DamageModule"))
Enabled = false
Combo = 1
local RS = game:GetService("ReplicatedStorage")

function performAction(c,t)
	local action = Instance.new("BoolValue",c)
	action.Name = "Action"
	game.Debris:AddItem(action,t+1)
end


function checkCombo(c)
	if Combo == 1 then
		Combo = 1
		local hand = c.RightHand
		local anim = c.Humanoid:LoadAnimation(c.Animate.uppercut.UppercutAnim)
		local t = anim.Length
		performAction(c,anim.Length)
		anim:Play()
		return anim
	end
end



script.Parent.OnServerEvent:Connect(function(player,action)
	local c = player.Character
	if Enabled == true then return end
	Enabled = true
	c.Humanoid.WalkSpeed = c.Humanoid.WalkSpeed*0.8
	checkCombo(c):GetMarkerReachedSignal("Hit"):Connect(function()
		dmgModule.Uppercut(player,action,c.LeftHand)
	end)
	wait(8) -- TIME BEFORE NEXT HEAVY
	Enabled = false
end)

This script works perfectly fine and I don’t get any issues with it.
The parenting of the scripts is very similar as well, only difference being that the localscript for the script above is a part of the backpack, not PlayerGui.
Even then, other scripts work perfectly fine within the PlayerGui, and testing whether a ServerScript works, being a part of the PlayerGui, with a simple print"example" also proves it should work.

Could you show us the hierachy for the tool or like whatever your using that is holding the remote event?

“Bridge” is the script that should be receiving the event, it’s parent, which is fired by the LocalScript “UnlockAbility”

Figured out what the issue was:

Since the button was a clone, I believe it was trying to check whether the original buttons event was being fired, which it was passing as false. thus letting the rest of the script continue.

My idea to fix this was just have the one dropdown who’s parent changes whenever you click on another skill to unlock, therefore the event will always be the one found in the original button.
Could have maybe specified which button I was looking for specifically, but I found it simpler to just move the button around to different parents instead.

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