Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

RemoteFunction not firing server?

I know this question has been asked a lot. This really stumped me.

--client
local function connectClasses() --to play button
	for _,v in pairs(menuclass:GetChildren()) do
		wait()
		if v:IsA('TextButton') then 
			if v.Name ~= 'Back' then 
				local inf = tinfo(.5,Enum.EasingStyle.Elastic)
				spawn(function()
					v.Button.MouseButton1Click:connect(function()
						--print('clickitied')
						spawn(function()
							ClassSelected:InvokeServer(plr,v.Name)
						end)
						local goal = {}
						goal.Position = menuout
						local t0 = twn(menuclass,inf,goal)
						t0.Completed:wait()
						gbls.Debris:AddItem(startmenu,0)
						spawned = true
						main.Enabled = true
						cam.CameraType = Enum.CameraType.Custom
					end)
				end)
			end
		end		
	end
end
--server
data.Combine("DATA","gold","sh_coins","class")

spawn(function()
	glbs.Plrs.PlayerAdded:connect(function(Plr)
		
		local goldstore = data("gold",Plr)
		local shcoinstore = data("sh_coins",Plr)
		local classstore = data("class",Plr)
		
		function callRemote(remote,value)
			sendDataToClient:InvokeClient(Plr,remote,value)
		end
		
		callRemote('Gold',goldstore:Get(500))
		callRemote('Stronghold Coins',shcoinstore:Get(0))
		callRemote('Class',classstore:Get('None'))
		
		goldstore:OnUpdate(callRemote)
		shcoinstore:OnUpdate(callRemote)
		classstore:OnUpdate(callRemote)
		
	end)
end)

classSelected.OnServerInvoke = function(Plr,Class)
	callRemote('Class',Class)
	return print('class remote called')
end

Any help is appreciated. I don't have any loops before any of this code.

1 answer

✓ Accepted answer

By default, the first parameter in the parameter list of ANY remote event or function is the invoking player (on the server). Meaning, you do not need to pass the player as an argument on the client.

ClassSelected:InvokeServer(plr,v.Name) should be ClassSelected:InvokeServer(v.Name)

1 comment

0

Thank you! I read somewhere yesterday that the player parameter was included in the client's firing. False info I guess.

This discussion is preserved as it was. New answers, comments, and votes are closed.