Remote event not being picked up on the server

local function kickMember(template)
	local name = template.NameLabel.Text
	game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("KickMember"):FireServer(name)
	print("sent")
end

thats the local script which is in starterplayerscripts and yes its printing “sent”

game.ReplicatedStorage.Remotes.KickMember.OnServerEvent:Connect(function(plr, name)
	for i,v in game.ReplicatedStorage.Parties:GetChildren() do
		if v.Name == plr.Name then
			print("equals")
			if v:GetChildren()[name] then
				v:GetChildren()[name]:Destroy()
				local kickedPlr = game.Players:GetPlayers()[name]
				local Party = Instance.new("Folder", game.ReplicatedStorage.Parties)
				Party.Name = kickedPlr.Name
				
				local plrValue = Instance.new("ObjectValue", Party)
				plrValue.Name = kickedPlr.Name
				plrValue.Value = kickedPlr
				game.ReplicatedStorage.Remotes.KickMember:FireClient(kickedPlr)
			end
		end
	end
end)

serverscript in serverscriptservice and it is not printing got

try adding a print statement in the server script before the logic

game.ReplicatedStorage.Remotes.KickMember.OnServerEvent:Connect(function(plr, name)
    print("remote on server test" , plr, name)
	for i,v in game.ReplicatedStorage.Parties:GetChildren() do
		if v.Name == plr.Name then
			print("equals")
			if v:GetChildren()[name] then
				v:GetChildren()[name]:Destroy()
				local kickedPlr = game.Players:GetPlayers()[name]
				local Party = Instance.new("Folder", game.ReplicatedStorage.Parties)
				Party.Name = kickedPlr.Name
				
				local plrValue = Instance.new("ObjectValue", Party)
				plrValue.Name = kickedPlr.Name
				plrValue.Value = kickedPlr
				game.ReplicatedStorage.Remotes.KickMember:FireClient(kickedPlr)
			end
		end
	end
end)

yea just tried that but didnt print for some reason

maybe you connected the server event after the client script had sent it?
add a print statement before the on server event line and see if it prints after or before the
"sent "print which is made on the client

if it printed after “sent” then its cause the on server event executed after the client has sent the event

and if it didn’t even print then something is blocking/yielding the code

thing is i fire the remote to the server every time i click a button and i have been doing that after the server has connected the function to the event

what I mean is that the server may not have connected the event
does this print “event connected on server” ?

print("event connected on server")
game.ReplicatedStorage.Remotes.KickMember.OnServerEvent:Connect(function(plr, name)
    print("remote on server test" , plr, name)
	for i,v in game.ReplicatedStorage.Parties:GetChildren() do
		if v.Name == plr.Name then
			print("equals")
			if v:GetChildren()[name] then
				v:GetChildren()[name]:Destroy()
				local kickedPlr = game.Players:GetPlayers()[name]
				local Party = Instance.new("Folder", game.ReplicatedStorage.Parties)
				Party.Name = kickedPlr.Name
				
				local plrValue = Instance.new("ObjectValue", Party)
				plrValue.Name = kickedPlr.Name
				plrValue.Value = kickedPlr
				game.ReplicatedStorage.Remotes.KickMember:FireClient(kickedPlr)
			end
		end
	end
end)

wait nevermind it has been firing the whole time, just that since i was in team test i was looking at the client output and not the server output

2 Likes

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