Attempt to concatenate Instance with string

Hey!

I’ve been recently trying to make a group ranking script, which works through website called “Glitch”.

However, when I fire an event for the rank up server script, I get an error.

attempt to concatenate Instance with string

I’m not really sure what to change, so any help would be appreciated.

Code for the FireEvent:

	elseif XP.Value == 6 then
		Level.Value = 1
		game.ReplicatedStorage.RankInGroup:FireServer(player.UserId, 1)

Code for the ServerScript:

local GlitchURL = "https://sfpd-xpsystem-rankingbot.glitch.me/"

game.ReplicatedStorage.RankInGroup.OnServerEvent:Connect(function(UserId, RoleId)
	local function rankUser(UserId, RoleId)
		game:GetService("HttpService"):GetAsync(GlitchURL .. "ranker?userid=" .. UserId .. "&rank=" .. RoleId)
	end
	
	rankUser(UserId, RoleId)
end)

I think maybe you only want to send the number to server: (no need to send the Player.UserId, server already knows who triggered it)

elseif XP.Value == 6 then
	Level.Value = 1
	game.ReplicatedStorage.RankInGroup:FireServer(1)

Then in server:

local GlitchURL = "https://sfpd-xpsystem-rankingbot.glitch.me/"

game.ReplicatedStorage.RankInGroup.OnServerEvent:Connect(function(Player, RoleId)
	game:GetService("HttpService"):GetAsync(GlitchURL.."ranker?userid="..tostring(Player.UserId).."&rank="..tostring(RoleId))
end)

OnServerEvent will call the callback with Player as the first argument, so it’s unnecessary for you to pass the player.UserId.

Here’s a simple example on how OnServerEvent works using your code

RemoteEvent:FireServer(player.UserId, 1)

-- Will result in
RemoteEvent.OnServerEvent:Connect(function(Player: Player, UserId: number, RoleId: number)
end)

-- Or in a more simple way
RemoteEvent:FireServer(a, b, c, d)

-- Will result in
RemoteEvent.OnServerEvent:Connect(function(player, a, b, c, d)
end)

This is why the “attempt to concatenate Instance with string” happened, it’s because you are trying to combine Player with string

Here’s the correct implementation by the comment above.

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