I get an error I have already resolved (I think)

Hi everyone,

I have been working on this for some time but I keep running into the same issue, this error:

ServerScriptService.GetPlayerInfo:4: attempt to concatenate string with Instance

keeps returning everthough I though I had already fixed it. It should been working al least. It works with 2 scripts, one server, the other local. The Localscript sends an remoteevent fire to the serverscript and than back. With that goes a variable callt “ID”. The ID is an stringvalue but and works in the local script, but when I use it in the serverscript it seems to not identify it like it should.

Serverscript:

local HttpService = game:GetService("HttpService")

game.ReplicatedStorage.GetGuilty.OnServerEvent:Connect(function(ID)
	local url = "https://users.roproxy.com/v1/users/" .. ID
	local success, response = pcall(function()
		return HttpService:GetAsync(url)
	end)

	if success then
		local data = HttpService:JSONDecode(response)
		local created = data.created 
		local year, month, day = string.match(created, "(%d+)%-(%d+)%-(%d+)")
		local joinDateText = day .. "/" .. month .. "/" .. year
		game.ReplicatedStorage.GetPlayerInfoResult:FireClient(joinDateText)
	else
		warn("F*ck up while getting Playerinfo", response)
	end
end)


Localscript:

local player = game.Players.LocalPlayer
local Players = game:GetService("Players")
local ID = script.Parent.Parent.ID.Value

script.Parent.MouseButton1Click:Connect(function()
	player.PlayerGui.UI.Background.ScrollingFrame.Visible = false
	
	local success, characterModel = pcall(function()
		return Players:GetCharacterAppearanceAsync(ID)
	end)

	if success and characterModel then
		characterModel.Parent = player.PlayerGui.UI.Background.InfoFrame.view.ViewportFrame.Sene
		characterModel:MoveTo(player.PlayerGui.UI.Background.InfoFrame.view.ViewportFrame.Sene.PlaceHolderRig.PrimaryPart.Position)
		player.PlayerGui.UI.Background.InfoFrame.view.ViewportFrame.Sene.PlaceHolderRig.Parent = player.PlayerGui.UI.Background.InfoFrame.view.ViewportFrame
	else
		warn("Couldn't find character")
	end
	
	player.PlayerGui.UI.Background.InfoFrame.Mugshot.ImageLabel.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=" .. ID .. "&width=420&height=420&format=png"
	
	game.ReplicatedStorage.GetPlayerInfo:FireServer(ID)
	
	game.ReplicatedStorage.GetPlayerInfoResult.OnClientEvent:Connect(function(Result)
		player.PlayerGui.UI.Background.InfoFrame.Joindate.Text = Result
	end)

	player.PlayerGui.UI.Background.InfoFrame.Visible = true
end)

Make sure the things you are ‘adding’ to strings, with the … are actually strings themselves.
Somwhere you are trying to combine a string and an instance.
Remember to use instance.Name, or tostring() if you need to add an instance to a string.

Hi, your error is inside the following line:

this “url” variable is a string, and at the end you are trying to add the ID Instance to it. This is not possible because an instrance cannot be converted to a string in any way, but since this particular instance is a StringValue you can just call its .Value property, and you are done!

	local url = "https://users.roproxy.com/v1/users/" .. ID.Value

Here is the documentation for further information.

Hey, the first parameters of the remoteEvent is the player, the second parameter is what you send through

That seemed to be it, it was way simpeler than I though. TYSM :slight_smile:

1 Like

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