"attempt to concatenate string with Instance"

so i was trying to make a Map voting gui, failed coding miserably, tried starting from sratch. Now i was doing a system to detect a player gui with server script service. And i got an error (see title). Here is the code i have got so far ´

local Players = game:GetService("Players")

local RS = game:GetService("ReplicatedStorage")

local Folder = Instance.new("Folder")

Folder.Name = "Players"

Folder.Parent = RS

Players.PlayerAdded:Connect(function(player)

--print(player.Name .. " joined the game!")

local StrVal = Instance.new("IntValue",Folder)

StrVal.Name = "Player:"..player

StrVal.Value = player

end)

And im starting to go crazy because everything im trying to do is failing. Please help

--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--//Initialization
local Folder = Instance.new("Folder")
Folder.Name = "Players"
Folder.Parent = ReplicatedStorage

--//Functions
Players.PlayerAdded:Connect(function(Player)
	--print(player.Name .. " joined the game!")

	local StringValue = Instance.new("StringValue")
	StringValue.Name = "Player:"..Player.Name
	StringValue.Value = Player.Name
	StringValue.Parent = Folder
end)
2 Likes

Change this to:

StrVal.Name = "Player: "..Player.Name
StrVal.Value = Player.Name
1 Like

You need to be accessing the Players UserId not instance:

StrVal.Name = "Player:"..player.UserId
StrVal.Value = player.UserId

thank you … I didnt recognize this mistake, i feel quite dumb now xD

Don’t worry, everyone makes mistakes!

1 Like