So I am making a murder game and I was trying to make it so it says the chosen game and spawns it in. I am doing this through a** LOCAL SCRIPT** because I am FireAllClients form the Script. Also the error is "Players.Nosh4309.PlayerGui.LocalScript:21: attempt to concatenate local 'gameChosen' (a userdata value)" What does this mean? I cant change it form not being local (Also the problem is** line 17 to 21**)
local client = game:GetService("Players").LocalPlayer local RepStore = game:GetService("ReplicatedStorage") local remote = RepStore.remote -- LOCATING THE REMOTE local repstore = game.ReplicatedStorage -- local Maps = repstore.Maps:GetChildren() local School = repstore.Maps.School local Beach = repstore.Maps.Beach remote.OnClientEvent:Connect(function() local pgui1 = client.PlayerGui pgui1:WaitForChild("ScreenGui").TextLabel.Text = "Starting game!" wait(3) local pgui = client.PlayerGui pgui:WaitForChild("ScreenGui").TextLabel.Text = "Choosing a map" wait(3) local RanGame = math.random(1,#Maps) local gameChosen = Maps[RanGame] --Problem is here local pgui = client.PlayerGui pgui:WaitForChild("ScreenGui").TextLabel.Text = "Map chosen ".. gameChosen --end wait(1) local gameChosenClone = gameChosen:Clone() if gameChosenClone.Name == "Beach" then Beach:Clone().Parent = game.Workspace.MapSelected elseif gameChosenClone.Name == "School" then School:Clone().Parent = game.Workspace.MapSelected end end)
You should cloning/moving/adding parts or groups in a server script instead of a client script. Also, you are cloning the maps two times.
Look:
local gameChosenClone = gameChosen:Clone() -- Here you clone the map chosen in the Maps[RanGame] if gameChosenClone.Name == "Beach" then Beach:Clone().Parent = game.Workspace.MapSelected -- Here you clone the map again if the map chosen in the Maps[RanGame] is named "Beach" elseif gameChosenClone.Name == "School" then School:Clone().Parent = game.Workspace.MapSelected -- Here you clone the map again if the map chosen in the Maps[RanGame] is named "School" end
Last thing, you forgot to get the name of the chosen map. Example:
local text = "Map Chosen: " .. gameChosen -- This is wrong, you miss the ".Name"
local text = "Map Chosen: " .. gameChosen.Name -- This is right, you are reading the chosen map's name
I hope it helped.