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

attempt to concatenate Instance with string error?

I have a remote event script which sends a remote event from the Client to Server, its sent with 2 variables, player and skin. When I run it it comes up with this error: ServerScriptService.Stats.Skins:66: attempt to concatenate Instance with string

Heres the script that is firing the event:

equip.MouseButton1Click:Connect(function()
	local function equipfunction(skin)
		if skinsstats[skin.."Skin"].Value == 0 then
			print("You dont own "..skin.."Skin")
		elseif skinsstats[skin.."Skin"].Value == 1 then
			game.ReplicatedStorage.Events.ChangeStats:FireServer(player, skin) -- Sends Event
			equip.Text = "Equipped"
		end
	end

	if displayframe:FindFirstChild("Name").Text == "Noob" then equipfunction("Noob") end
	if displayframe:FindFirstChild("Name").Text == "Bussiness Man" then equipfunction("BussinessMan") end
	if displayframe:FindFirstChild("Name").Text == "Old Man" then equipfunction("OldMan") end
end)

And heres the script that is receiving it:

game.ReplicatedStorage.Events.ChangeStats.OnServerEvent:Connect(function(player, skin)
	print("Recieved")
	local skinsstats = player.skins
	local children = skinsstats:GetChildren()
	for i, child in ipairs(children) do
		if child.Value >= 2 then
			child.Value = 1
		end
	end
	skinsstats[skin.."Skin"].Value = 2
	print("Success")
end)

1 answer

The problem here is that you have 'player' in your FireServer function, it isn't needed as it automatically gets the player when they fire the RemoteEvent to the server. When you're passing (player, skin), 'player' in your FireServer function is actually being assigned to 'skin' in your OnServerEvent. Simply remove 'player' from your FireServer function and it should work.

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