nights = {[1] = "monster1",[2] = "monster2"}
Client
game.ReplicatedStorage.start:FireServer(v.Name)
Server
game.ReplicatedStorage.start.OnServerEvent:Connect(function(n) for i,model in pairs(game.ServerStorage:GetChildren()) do if string.match(nights[tonumber(n)],v.Name) then model:Clone().Parent = workspace end end end)
output
ServerScriptService.send:61: bad argument #1 to 'match' (string expected, got nil)
Basically the client is sending a object's name, The server is going through the table and seeing if the string matches with any children in server storage If there's a easier way to do this please tell me, This is really confusing ;'/
change server code to this
game.ReplicatedStorage.start.OnServerEvent:Connect(function(player,n) for i,model in pairs(game.ServerStorage:GetChildren()) do if string.match(nights[tonumber(n)],v.Name) then model:Clone().Parent = workspace end end end)