#attempt to index nil with wait for child

1 messages · Page 1 of 1 (latest)

shell monolith
#

thats the error am getting when am referencing a part for a variable, when before i click play the part is there, but once i click play it disappears. and am not destroying it in any script??

fleet slate
#

do you have a pic of the script. It could help

shell monolith
#

'v'

#

"v"

#

'v'

#

''v''

#

v

#

v

#

what the um thingy for code

#

v

#

nvm

#

local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() local HRP = char:WaitForChild("HumanoidRootPart") local startPosition = workspace:WaitForChild("start").Position local endPosition = workspace:WaitForChild("End").Position

#

the error is the last part (local endPosition = bla bla) @fleet slate

mellow star
#

Make sure "workspace.End" exist

shell monolith
#

it does

#

I've been on this for the past hour

#

it exists before i press play, when i press play it disappears

#

and am not destroying it or changing the parent at all, am literally only using the part for the position

#

and its not falling out of the world cuz its anchored

mellow star
#

I would try seeing if getting the position after would help

shell monolith
#

wym

mellow star
#

After you wait for the part

shell monolith
#

oh

#

lemme try

#

doesnt work

#

but ig it wont cuz the part doesnt exist when i hit play

#

it works fine for start position, but not end position?

#

???

mellow star
#

What if u copy startPosition block and replace the endPosition

#

To make sure their exactly the same

#

Also what happens when you click "Run"

shell monolith
#

am not clicking "run" and clicking play

mellow star
#

Well if u click run does it dissapear

shell monolith
#

but it does when i click play

fleet slate
#

is there any other references to these parts in other scripts

shell monolith
#

all of a sudden when i buy the dev product everything starts working?

#

.

mellow star
#

😨

shell monolith
#

bro i want to fling my computer out the window rn, nothing makes sense

fleet slate
#

I'm not sure i'm following. Indexing nil means it does not exist and has no parent, so something has to be wrong. If it's a local script wouldn't hurt to but a task.wait(2) at the top

shell monolith
#

it exists on the server and not the client

#

how does that even make sense

#

i didnt instance it

fleet slate
#

a wild guess here, but if streaming enabled is on, and the parts are super far away from your spawn, then on the client those parts don't exist yet

shell monolith
#

hm

#

i think thats the issue

#

cuz the end part is like 1300 studs away from spawn

#

how do i turn off streaming enabled

fleet slate
#

try bringing it next to the spawn, test to see if it errors and if it does, click on workspace and turn streaming enabled off

#

i mean if it doesnt error*

mellow star
#

I didn't think :WaitForChild() would throw an error if the part doesn't exist

#

At worst would warn "Infinite Yeild Possible"

fleet slate
#

I usually get an infinite yield warning as well ye

mellow star
#

Yea

#

That's about all I've gotten

shell monolith
#

AH YES IT WORKS

#

I LOVE U MAN

#

TY TY

fleet slate
#

np glad it works

shell monolith
#

btw... whats streaming enabled?

mellow star
#

Streaming Enabled is so dumb sometimes

fleet slate
#

streaming enabled is dumb yeah, but it's for slower devices to load in places as they get closer

shell monolith
#

so if i turn it off, is that a bad thing for my game?

fleet slate
#

unless you have a super massive game with high poly count buildings/items, then no it'll be fine

shell monolith
#

ok nice

mellow star
#

^

shell monolith
#

ty for yalls help

#

help*

fleet slate
#

no problem

mellow star
#

I learn more and more about Streaming Enabled from issues than anything else 😨

shell monolith
#

btw

#

another question

#

how do i set a place other than the start place to public

fleet slate
#

is the other place an asset in the game?

shell monolith
#

u mean like apart of the game?

fleet slate
#

like you created it in asset manager

shell monolith
fleet slate
#

well it will always be public as long as the main game is public, but you'll need to use teleportservice for players to enterit

shell monolith
#

oh, when i try to teleport it says restricted access

fleet slate
#

if you're trying in studio then it will throw that error

#

unless you tried on roblox

shell monolith
#

`local TeleportService = game:GetService("TeleportService")
local SafeTeleport = require(game:GetService("ServerScriptService").SafeTeleport)

telePart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent

    local placeId = 16868752131
    local players = {game.Players:GetPlayerFromCharacter(hit.Parent)}
    
    local server = TeleportService:ReserveServer(placeId)
    local options = Instance.new("TeleportOptions")
    options.ReservedServerAccessCode = server
    SafeTeleport(placeId,players,options)
    
    print("finished teleport")
    
    
end

end)
`

fleet slate
#

the placeId is from your asset manager right?

shell monolith
#

yh

fleet slate
#

I haven't made a game in a minute, but let me check out one of mine that uses teleport

shell monolith
#

mk

fleet slate
#

well in my other places it looks like public is enabled as well in game settings

#

but i cant remember if i had to set that or not

shell monolith
#

i made a change lemme test it rq'

#

it works nvm

#

ty