#Map is not spawning

1 messages · Page 1 of 1 (latest)

obsidian ether
#

this remote doesnt work idk why

 lua 
local lastmap = nil

local map = game.ReplicatedStorage:FindFirstChild("maps")

map.OnClientEvent:Connect(function()
    local mapsFolder = game.ReplicatedStorage.maps
    local allMaps = mapsFolder:GetChildren()


    local newmapIndex
    repeat
        newmapIndex = math.random(1, #allMaps)
    until newmapIndex ~= lastmap

    lastmap = newmapIndex
    local selectedMap = allMaps[newmapIndex]


    game.Workspace.Values.CurrentMap.Value = selectedMap.Name

    for _, v in pairs(game.Workspace.Map:GetChildren()) do
        v:Destroy()
    end


    local newMapClone = selectedMap:Clone()
    newMapClone.Parent = game.Workspace.Map
end)
lament condor
#

is maps the folder or event? You use it like both an event and a folder

blissful void
#

maps is the folder

lament condor
blissful void
#

idk

blissful void
#

maybe im wrong

obsidian ether
lament condor
#

show me ReplicatedStorage

blissful void
#

okay wait

lament condor
blissful void
#

btw the code is inside a localscript

blissful void
#

hold up

#

am i stupid

lament condor
blissful void
#

but

#

maps is the folder

#

that im gonna put the map inside

#

oh

#

bruh

#

im dumb

serene hemlock
blissful void
#

well

#

still doesnt work

#
local lastmap = nil

local rmap = game.ReplicatedStorage.RandomMap

local map = game.ReplicatedStorage:FindFirstChild("maps")

rmap.OnClientEvent:Connect(function()
    local mapsFolder = game.ReplicatedStorage.maps
    local allMaps = mapsFolder:GetChildren()


    local newmapIndex
    repeat
        newmapIndex = math.random(1, #allMaps)
    until newmapIndex ~= lastmap

    lastmap = newmapIndex
    local selectedMap = allMaps[newmapIndex]


    game.Workspace.Values.CurrentMap.Value = selectedMap.Name

    for _, v in pairs(game.Workspace.Map:GetChildren()) do
        v:Destroy()
    end


    local newMapClone = selectedMap:Clone()
    newMapClone.Parent = game.Workspace.Map
end)
#

or am i just dumb

lament condor
blissful void
#

i get no errors

#

and i fire it with FireAllClient since its inside a localscript

#

the locascript is in workspace

#

maybe thats the issue

#

and

#

its not doing anything

#

the main issue is that a random map doesnt spawn into the map

lament condor
blissful void
#

Lmao let me try putting it in startercharacter

#

nop doesnt work

#

and no errors

serene hemlock
#

try putting a bunch of prints to see what works and what doesnt

lament condor
serene hemlock
#

it works for me most of the time

blissful void
serene hemlock
#

e

#

jus run the game

lament condor
blissful void
#

oh

#

oopsie

#

let me try a server script then

blissful void
#

it works 🤯

#

now uh

#

just to make sure

#

do i always put remotes that affect the client in a locascript?

#

or the code

#

in a localscript

lament condor
blissful void
#

and what do i put in server and what do i put in local

lament condor
blissful void
#

alright. And another question. if i want to teleport everyone to a random part. do i use client or server.

serene hemlock
#

i think its more of a servr

#

becuz its gonna be teleport service

blissful void
#

i have it currently in a server script but everyone gets teleported to the same part.

serene hemlock
lament condor
blissful void
#

i can send u the code

molten oracle
lament condor
blissful void
#
inter.OnServerEvent:Connect(function(player)
    local spawn = game.Workspace.SpawnInter:GetChildren()

    if #spawn == 0 then
        warn("No spawn points available.")
        return
    end


    local rspawn = spawn[math.random(1, #spawn)]


    local targetPosition = rspawn.Position + Vector3.new(0, 3, 0)


    for _, otherPlayer in pairs(game.Players:GetPlayers()) do
        if otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
            otherPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(targetPosition)
        end
    end
end)
#

its a remote too

molten oracle
#

yea your only choosing 1 spawn position for all players

#

something like I said would work

blissful void
#

how do i use ur code then

lament condor
blissful void
#

cus uh

#

i dont understand

molten oracle
#
 
inter.OnServerEvent:Connect(function(player)
    local spawn = game.Workspace.SpawnInter:GetChildren()

    if #spawn == 0 then
        warn("No spawn points available.")
        return
    end

    for i, otherPlayer in pairs(game.Players:GetPlayers()) do
        if otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
            otherPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(spawn[i].Position + Vector3.new(0, 3, 0))
        end
    end
end)
blissful void
#

thanks

molten oracle
#

np

rough nicheBOT
#

studio** You are now Level 6! **studio

molten oracle
#

so now it gets the part at i position and it teleports the player there

molten oracle
#

and does that for each player

blissful void
#

cus i dont want that happening

blissful void
#

oof

#

how do i prevent that

serene hemlock
#

exploiters cant access them i think

#

or server script servce

#

stuff like that

blissful void
lament condor
molten oracle
serene hemlock
blissful void
molten oracle
#

um

#

it shouldnt

#

is your code the same as mine?

blissful void
#

uh

#

i have all my remotes in 1 script

molten oracle
#

and how many parts are in spawnInter

blissful void
molten oracle
#

are they all at different positions

blissful void
#

yeah

molten oracle
#

hm

blissful void
#
inter.OnServerEvent:Connect(function(player)
    local spawn = game.Workspace.SpawnInter:GetChildren()

    if #spawn == 0 then
        warn("No spawn points available.")
        return
    end

    for i, otherPlayer in pairs(game.Players:GetPlayers()) do
        if otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
            otherPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(spawn[i].Position + Vector3.new(0, 3, 0))
        end
    end
end)```
molten oracle
#

weird

#

your doing a multi player test in studio?

blissful void
#

no

#

single player

molten oracle
#

like

#

testing with multiple clients

#

or just you

blissful void
#

just me

molten oracle
#

well there is only 1 player

#

thats why

blissful void
#

oh

#

but

#

i want it to spawn the player at one of the random spawns

#

in spawninter

molten oracle
#

click start on here to do multi player test

#

all players spawn at different places instead of the same one as each other

blissful void
#

there is only me and a server

#

oh

#

wait

molten oracle
#

increase the amount of players

blissful void
#

this is how they spawned

#

maybe its just bad rng

molten oracle
#

its not based on rng anymore tho

blissful void
#

true true

#

well

#

its working better than before

#

and i really gotta go

molten oracle
#

alr

#

cya

blissful void
#

maybe u can help sometime later

#

cya dude

molten oracle
#

yea

#

ping me if u need smth

blissful void
#

@molten oracle

#

hi

#

i might need ur help again

molten oracle
#

hi

blissful void
#

yo

molten oracle
#

with what do you need help with

blissful void
#

the other remotes

#

basically. i have 3 remotes, one for spawning the map. one for teleporting all players too the map and one that teleports all to the intermission place

molten oracle
#

mhm?

blissful void
#

and uhm

#

the remotes kind of work

#

but the problem is

#

the script we fixed yesterday

#

with the map spawning is local

#

the server cant find it

molten oracle
#

why do you need remote events

#

for spawning a map

blissful void
#

idk i thought it was the best to use remotes for that

molten oracle
#

just spawn it in the server script and all clients will be able to see that

blissful void
#

oh

molten oracle
#

no need for remotes lol

blissful void
#

so

#

my remotes are just useless?

molten oracle
#

spawning and teleporting is server side stuff

#

only do that server side most of the time

blissful void
#

oh

#

what do i use remotes for then

molten oracle
#

say a user presses a button that increases their cash, a remote would tell the server "Hey, the player pressed the button so increase this number"

#

on the other hand if a server wanted to open a gui on a certain player (or all players depending on the use case) then the remote would tell the client "Hey, open this gui"

blissful void
#

oh

#

when i did gui i just changed the visible thing

#

with local script

#

or isnt that the same thing

#

probably not

#

so uh i might need some help to make this work now

#

do i need a remote to spawn a random mob

#

entity

molten oracle
#

no

#

that would be server side

blissful void
#

so this wont work

games.OnServerEvent:Connect(function(player)
    local spawnContainer = game.Workspace.Map:FindFirstChildOfClass("Model")

    if not spawnContainer then
        warn("No Model found — map contents may not be loaded yet.")
        return
    end

    local spawns = spawnContainer:FindFirstChild("Spawn"):GetChildren()

    if #spawns == 0 then
        warn("Spawn folder is empty — no spawn points available.")
        return
    end
    
    local spawn = spawns[math.random(1, #spawns)]

    for _, otherPlayer in pairs(game.Players:GetPlayers()) do
        if otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
            otherPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(spawn.Position + Vector3.new(0, 3, 0))

            local mob = rmob()
            print(mob and mob.Name or "No mob found")
        end
    end
end)

rmob

local function rmob()
    local mobs = game.ReplicatedStorage.mobs
    local bob = nil

    local modelMobs = {}
    for _, v in pairs(mobs) do
        if v:IsA("Model") then
            table.insert(modelMobs, v)
        end
    end

    if #modelMobs > 0 then
        bob = modelMobs[math.random(1, #modelMobs)]
    end

    return bob
end
molten oracle
#

where are you calling the remote event

blissful void
#

i dont

#

yet

molten oracle
#

where will you

blissful void
#

uh

#

in a script sometime

molten oracle
#

For a round system you dont need any remote events

blissful void
#

oh

molten oracle
#

that can all be in the same server script

blissful void
#

dang

molten oracle
#

look up a round system tutorial

#

might be helpful

blissful void
#

Lmao alright

#

so i can just remove all the remotes rn?

molten oracle
#

yea

blissful void
#

maybe make them functions

#

instead

molten oracle
#

but then modify your scripts

#

look up a tutorial then make the system

#

probably best if you dont know how to make a round system

#

good luck, ping me if you need anything

blissful void
#

alright

#

thanks

blissful void
#

@molten oracle

#

okay i might need ur help now

molten oracle
#

hi

#

what now

blissful void
#

uh i dont think the map is randomly chosen.

#

heres the code

#
local function getmap()
    
    local map = game.ReplicatedStorage:FindFirstChild("maps")

    local mapsFolder = game.ReplicatedStorage.maps
    local allMaps = mapsFolder:GetChildren()


    local newmapIndex
    repeat
        newmapIndex = math.random(1, #allMaps)
    until newmapIndex ~= lastmap

    lastmap = newmapIndex
    local selectedMap = allMaps[newmapIndex]


    game.Workspace.Values.CurrentMap.Value = selectedMap.Name

    for _, v in pairs(game.Workspace.Map:GetChildren()) do
        v:Destroy()
    end


    local newMapClone = selectedMap:Clone()
    newMapClone.Parent = game.Workspace.Map
end
molten oracle
#

hm

#

how many maps are there

blissful void
#

6

molten oracle
#

what one is being chosen every time

blissful void
#

uh

#

let me check

#

its random everytime i launch the game

#

but after that its the same map every round

molten oracle
#

where are you setting last map

blissful void
#

wdym

molten oracle
#

the variable

#

lastmap

blissful void
#

outside the function

#

ohhh

#

thats why

molten oracle
#

oh

blissful void
#

or

#

is that the issue

molten oracle
#

idk

#

uh

#

print the newmapindex inside the loop

blissful void
#

wait no

#

the uh

#

newmap is inside the func

molten oracle
#

yea

#

uh

#

try printing what I said

#

in the loop

blissful void
#

what loop

#

the rounding system?

molten oracle
#
repeat
  newmapIndex = math.random(1, #allMaps)
  print(newmapIndex)
until newmapIndex ~= lastmap
blissful void
#

where do i put that

molten oracle
#

its in your function you sent

blissful void
#

okay ill playtest now

molten oracle
#

alr send me a screenshot of the output

blissful void
#

alr so. the print is 5 because idk. but ik its the map and it doesnt even print a new one

molten oracle
#

where are you calling the function

#

send that part of your scripts

blissful void
#
local INTERMISSIONTIME = 5
local GAMETIME = 10

while true do
    if game.Workspace:GetAttribute("Intermission") == false then
        intermission()
        print("Starting game in : " .. tostring(INTERMISSIONTIME))
        task.wait(INTERMISSIONTIME)
    end
    
    
    local mapFolder = game.Workspace.Map
    
        if not mapFolder:FindFirstChildOfClass("Model") then
            getmap()
        end
            repeat task.wait(0.5) until mapFolder:FindFirstChildOfClass("Model")
            
            if mapFolder:FindFirstChildOfClass("Model") then
            game.Workspace:SetAttribute("Loadedmap", true)
                game.Workspace:SetAttribute("Map", mapFolder:FindFirstChildOfClass("Model").Name)
            end
            
            task.wait(2)
        
            gamestart()
                print("Game ending in : " .. tostring(GAMETIME))
                task.wait(GAMETIME)
                
            
        
    task.wait(1)
end
molten oracle
#

its because your only getting a new map if there is no map

#

but your not destroying the old map

blissful void
#

oh

#

oh yeahhh

#

i forgor to add the removal of the map

#

dang

molten oracle
#

yea

#

does that work now?

blissful void
#

yeah

#

also

#

another thing

#

the mob doesnt spawn

molten oracle
#

send code

blissful void
#
local function rmob()
    local mobs = game.ReplicatedStorage.mobs
    local bob = nil

    local modelMobs = {}
    for _, v in pairs(mobs:GetChildren()) do
        if v:IsA("Model") then
            table.insert(modelMobs, v)
        end
    end

    if #modelMobs > 0 then
        bob = modelMobs[math.random(1, #modelMobs)]
    end

    return bob
end

and

local function gamestart()
    local spawnContainer = game.Workspace.Map:FindFirstChildOfClass("Model")

    if not spawnContainer then
        warn("No Model found — map contents may not be loaded yet.")
        return
    end

    local spawns = spawnContainer:FindFirstChild("Spawn"):GetChildren()

    if #spawns == 0 then
        warn("Spawn folder is empty — no spawn points available.")
        return
    end
    
    local spawn = spawns[math.random(1, #spawns)]

    for _, otherPlayer in pairs(game.Players:GetPlayers()) do
        if otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
            otherPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(spawn.Position + Vector3.new(0, 3, 0))

            local mob = rmob()
            print(mob and mob.Name or "No mob found")
            mob.Parent = game.Workspace
            mob.Torso.Position = game.Workspace.Map:FindFirstChildOfClass("Model").MobSpawn.Position + Vector3.new(0,1,0)
        end
    end
end
molten oracle
#

your not cloning it

#

so its getting it straight from replicated storage

blissful void
#

oh

#

what do i change then

molten oracle
#

bob = modelMobs[math.random(1, #modelMobs)]:Clone()

blissful void
#

like this?

molten oracle
#

yea

#

test that

blissful void
#

i mean not really

molten oracle
#

is the blue block the mob?

blissful void
#

well

#

its not supposed to

#

its supposed to be a model but its a block

#

i didnt check if the model was there

molten oracle
#

oh

blissful void
#

but ik the mob doesnt look like that

molten oracle
#

you need to set its primary part cframe

#

your only setting torso

blissful void
#

so like this?

mob.CFrame.Position = game.Workspace.Map:FindFirstChildOfClass("Model").MobSpawn.Position + Vector3.new(0,1,0)
molten oracle
#

set the primary part of the model to torso then do

blissful void
#

ServerScriptService.Rounding:66: attempt to call a nil value

#
local function gamestart()
    local spawnContainer = game.Workspace.Map:FindFirstChildOfClass("Model")

    if not spawnContainer then
        warn("No Model found — map contents may not be loaded yet.")
        return
    end

    local spawns = spawnContainer:FindFirstChild("Spawn"):GetChildren()

    if #spawns == 0 then
        warn("Spawn folder is empty — no spawn points available.")
        return
    end
    
    local spawn = spawns[math.random(1, #spawns)]

    for _, otherPlayer in pairs(game.Players:GetPlayers()) do
        if otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
            otherPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(spawn.Position + Vector3.new(0, 3, 0))

            local mob = rmob()
            print(mob and mob.Name or "No mob found")
            mob.Parent = game.Workspace
            mob:SetPrimaryPartCFrame(CFrame.New(game.Workspace.Map:FindFirstChildOfClass("Model").MobSpawn.Position + Vector3.new(0,1,0)))
        end
    end
end
molten oracle
#

of uh

#

oh

#

CFrame.new

#

no uppercase

#

my bad

blissful void
#

no worries

molten oracle
#

does that work?

blissful void
#

well

rough nicheBOT
#

studio** You are now Level 7! **studio

blissful void
#

i belive so

molten oracle
#

alr

blissful void
#

let me test some

molten oracle
#

again, ping me if you need anything

#

I gtg for a bit

#

cya

blissful void
#

@molten oracle yo i need ur help agian lmao

serene hemlock
#

there is no way

#

you came back to this

blissful void
#

lmao

#

nah i just need help with a animation

serene hemlock
#

after a good month

#

i can try to help

blissful void
#

alright

serene hemlock
#

i have had animation experiences

blissful void
#

nice

#

its not about making animations tho

serene hemlock
#

ik

blissful void
#

just adding animations to a npc

serene hemlock
#

oh

#

its super easy

blissful void
#

it is?

#

well

#

i cant do it somehow

#

so how do i do it

serene hemlock
#
local npc = game.workspace:FindFirstChild("npc")
---HERES THE MAIN THING---
local animator = npc:FindFirstChild("Animator")
local animtrack = animator:LoadAnimation("animationidhere")
animtrack:Play()
#

lmk if theres any errors

blissful void
#

uh

#

not like that

#

like

#

we have a npc that follows u

#

and we need animations there

#

also does the animation get affected by being put in replicatedStorage

serene hemlock
#

just put

#

local anim = replicatedstorage.animation.AnimationId

serene hemlock
blissful void
#

yeah

serene hemlock
#

i see

blissful void
serene hemlock
#

what type

#

of rig is that

blissful void
#

r6

#

i belive

#

if r6 is the one without meshs then

#

yeah

serene hemlock
#

ok

#

yea

#

hgood

#

so

#

go into the rig

#

and find animate

#

and open its children

blissful void
#

there is no

serene hemlock
#

(not the script but the inside it)

#

what

blissful void
#

there is no animate

#

or

#

wdym

serene hemlock
#

what did u spawn the rig with

#

moon animator rig or sum

blissful void
#

uh

#

idk

#

my friend found it somewhere

#

and

#

decided to use it

#

wait

#

no

#

he made the rig from the uh

#

thing

serene hemlock
#

use robloxes built in sysmte

#

if u dont see it

blissful void
#

yeah

serene hemlock
#

try creating a new one

#

but a blocky one

#

lmk what u see

blissful void
#

wait

#

where and what should i see

serene hemlock
#

so

#

go into avatar

#

create

#

character*

#

and create r6 blocky

#

lmk if u see animate

blissful void
#

oh

#

yeah

#

heres the other rig tho. should i just add the animate there.

serene hemlock
#

hmmm

#

try to open humanoid root part

blissful void
#

which one

serene hemlock
#

the insane noob one

blissful void
#

alr

#

RootJoint

#

its the only thing there

serene hemlock
#

ok so uh

#

try to copy the animate

#

from rig 1

#

and post it into rig 2

#

and see what it does

blissful void
#

uh

#

do i paste it into the one inside replicated

#

so

#

it can spawn

#

ig

serene hemlock
#

no

#

put it inside the rig

blissful void
#

alr

#

the insane noob?

serene hemlock
#

yes

#

from test rig to insane noob

blissful void
#

alr

#

yeah nothing happens

serene hemlock
#

so the animation didnt change from

#

robloxes normal

#

to sum else

blissful void
#

uh

#

it doesnt have animation at all

#

just

#

floiats

#

floats

serene hemlock
#

i see

#

what about before

blissful void
#

uh

#

no

#

floats too

serene hemlock
#

ok can you send me

#

the uh entirety of the rig ai

blissful void
#

the entire ai script?

serene hemlock
#

what about that vs things

#

or whatever it is

blissful void
#

huh

serene hemlock
blissful void
serene hemlock
#

what is inside it

blissful void
serene hemlock
#

i see

#

wait a minute the humanoid has no animator

#

u can add it in there

blissful void
#

huh

#

wdym

#

alright

#

added itr

serene hemlock
#

ok

blissful void
#

now?=

serene hemlock
#

name this whatever u want and in there add climb fall idle jump run sit toolnone walk and make ALL OF THEM STRING VALUEs

#

then change the values of them to whatever u want

blissful void
#

uh

#

wdym

serene hemlock
#

change the string values

#

to the animation ids

blissful void
#

oh

#

i thought i had to make string values

#

like

#

instance.new

serene hemlock
#

no lol

#

why would i do tht

blissful void
#

idk

serene hemlock
#

server script

blissful void
#

alr let me try

serene hemlock
#

lmk if it works

#

@blissful void

blissful void
#

well

#

yues

#

thanlk u for the help dude