ServerScriptService.Script:4: attempt to concatenate nil with string

Hi there. I’m trying to make a group rank script, but I get this error.
localscipt:

local event = game.ReplicatedStorage.RankEvent

script.Parent.MouseButton1Click:Connect(function()
	local UserId = tonumber(script.Parent.Parent.UserID.Text)
	local RankId = tonumber(script.Parent.Parent.RankID.Text)

	if not UserId or not RankId then return end

	event:FireServer(UserId, RankId)
end)

serverscript:

local GlitchURL = "https://###########/" --Place the glitch project URL inside of the quotes

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

end)
end


game.ReplicatedStorage.RankEvent.OnServerEvent:Connect(function(player, UserId, RoleId)
	rankUser(UserId, RoleId)
end)

I tagged the URL because I don’t know if someone could do something to my group or not.
error:
ServerScriptService.Script:4: attempt to concatenate nil with string

May be because you are sending the player to the server. FYI, a remote evnt from client already sends the player, so remove the player part in the remote event. That should fix it, because you are sending two players.wd

2 Likes

Still the same error though…

Are you sure? Did you remove the player argument in the local script? Also, try printing UserId and RoleId on both the server and client.

Hi!

UserId or RankId returns probably nil. This may be because of the text. If it contains a letter, it’ll return nil because you use tonumber. Check the texts if it does.

tonumber("12312331") 
--123123331

tonumber("123123321a")
--nil

I will send a video of me entering the UserId and the RoleId to show ya’ll.

I think the issues stem from:
script.Parent.Parent.UserID.Text
script.Parent.Parent.RankID.Text

Not exactly sure how, but to think of it, the text might have converted to nil when it contained non-numbers. It’s somewhere around about user’s input to change the text not working as intended?

I might be wrong but I’m pretty sure you don’t need to pass the client when firing to the server, and MouseButton1Click doesn’t return a player.

Also you may want to check if the userid and rankid is valid.

local event = game.ReplicatedStorage.RankEvent

script.Parent.MouseButton1Click:Connect(function()
	local UserId = tonumber(script.Parent.Parent.UserID.Text)
	local RankId = tonumber(script.Parent.Parent.RankID.Text)

    if not UserId or not RankId then return end
	
	event:FireServer(UserId, RankId)
end)
2 Likes


I don’t think that’s the case.

I tried that.
Now I get this error:
ServerScriptService.Script:4: attempt to concatenate Instance with string

Remove player from it, when you fire it ‘UserId’ is being sent as the player instance.

I’ve already removed player from it.

Try printing UserId and RoleId, tell me what outputs.

1 Like

In both scripts?

charsss

Only inside the serverscript for your remote.

1 Like
print(UserId)
print(RoleId)

15:52:55.782 Cats767_99 - Server - Script:10
15:52:55.782 2330509080 - Server - Script:11

Why is it there twice and the one that is above does not have the player parameter.

Literally just realized that, lol.

I didn’t mean for that to be there, but I don’t think that contributes the to error as I removed it and am still getting the same error.

Can you show me your serverscript? (The current one)