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)
