Why isn't my remote function working?

I’ve been messing around with my script, trying numerous different things, but when I tried to use OnServerInvoke within my remote function, it doesn’t print., nor does it pass arguments that I wish for it to pass… Below you’ll find the scripts I’ve been using to invoke my function. Hopefully its a simple fix.

Serverscript

local replicatedStorage = game:GetService("ReplicatedStorage")
local iconFunction = replicatedStorage.IconChangeFunction
local Players = game:GetService("Players")

iconFunction.OnServerInvoke = function(player, Image)
		print("Testing", Image)
		local Playerlist = player.PlayerGui.Playerlist
		local Template = Playerlist.Frame.Handler.Template
		local Icon = Template.Icon
			if Icon.Image then
				
				
				
				
			end
			
		end

	

Localscript

localPlayer:GetPropertyChangedSignal("Team"):Connect(function()
	local function localIconChange()
	for i, value in pairs(TeamArray) do
		if localPlayer.TeamColor == TeamArray[1] then
			Icon.Active = true
			Icon.Image = iconImageArray
		elseif localPlayer.TeamColor == TeamArray[2] then
			Icon.Active = true
			Icon.Image = iconImageArray[2]
		elseif localPlayer.TeamColor == TeamArray[3] then
			Icon.Active = true
			Icon.Image = iconImageArray[3]
		elseif localPlayer.TeamColor == TeamArray[4] then
			Icon.Active = true
			Icon.Image = iconImageArray[4]
		elseif localPlayer.TeamColor == TeamArray[5] then
			Icon.Active = true
			Icon.Image = iconImageArray[5]
		end
		
		iconFunction:InvokeServer(Icon.Image)
1 Like

The part where you actually Invok the server, put a print there and see if its running

1 Like

nope, it isn’t running for some odd reason

image

1 Like

nothing printed, unfortunately

1 Like

You are just creating a new function inside the callback function i.e. local function localIconChange() is being defined inside the callback, which does nothing.
Move the contents of the function localIconChange outside and start debugging.
That’s the issue you’re facing.

1 Like

so outside of the localPlayer:GetPropertyChangedSignal(“Team”):Connect(function()?

and call it later on once it’s outside of the getpropertychangedsignal?

localPlayer:GetPropertyChangedSignal("Team"):Connect(function(): ()
    for i, value in pairs(TeamArray) do
		if localPlayer.TeamColor == TeamArray[1] then
			Icon.Active = true
			Icon.Image = iconImageArray
		elseif localPlayer.TeamColor == TeamArray[2] then
			Icon.Active = true
			Icon.Image = iconImageArray[2]
		elseif localPlayer.TeamColor == TeamArray[3] then
			Icon.Active = true
			Icon.Image = iconImageArray[3]
		elseif localPlayer.TeamColor == TeamArray[4] then
			Icon.Active = true
			Icon.Image = iconImageArray[4]
		elseif localPlayer.TeamColor == TeamArray[5] then
			Icon.Active = true
			Icon.Image = iconImageArray[5]
		end
    end
    iconFunction:InvokeServer(Icon.Image)
end)

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