Hey Developers, I’m working on a script for my game that teleports a player to a spawn after they press a GUI button via a remote event. But, I couldn’t find a way to address the player model. So I came up with a idea to join game.Workspace to the player name. But, it gives me a error reading “ServerScriptService.InputPlayerScript:7: attempt to concatenate string with Instance”
The script is right here.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("addPlayer")
local Spawns = game.Workspace.Map.CorruptCastle.Spawns:GetChildren()
local function insertPlayer(player)
local playerValue = "game.Workspace." .. player
print("game.Workspace" .. player)
playerValue.CFrame = Spawns[math.random(#Spawns)].CFrame.Position
end
remoteEvent.OnServerEvent:Connect(insertPlayer)
I don’t know what else to do, help is appreciated.