#Issue with reloading the car after a threshold is reached

1 messages · Page 1 of 1 (latest)

thick sphinx
#

hello I am new to Roblox scripting, and I need help on this issue. I am trying to achieve making a car destroy after when it flips upside down, I managed to do that sucessfully. But when I walk into the rangePart, which is used for spawning the car when the player gets within a certain range, It doesn't want to respawn again.

NOTE: I spawned the car upside down on purpose for debugging purposes, and i also have all the boolean variables printed for debugging purposes. I really need help, thank you.

viscid nebula
#

get rid of this bit and do something like
newCar.PrimaryPart = newCar:WaitForChild("Chassis")
so the primary part it's using is inside the copied car

#

@thick sphinx

thick sphinx
#

ok let me see

#

@viscid nebula i changed it in the touched method

#

like this

#

??

viscid nebula
#

you dont need to do 'primary part =' cause youve already set it. also make sure your parenting it first before setting the primary part @thick sphinx

#

also dont have the primary part set outside the functions remove the entire local primary part line at the top

narrow estuary
#

oh

#

hey

#

whats the problem

thick sphinx
#

ok so basically

#

as you can see here this code is supposed to spawn a car once the player walks into a rangePart, the first iteration it works then when the car is destroyed and i try to spawn it again for some wierd reason it doesn't

narrow estuary
#

okay

quasi pecanBOT
#

studio** You are now Level 1! **studio

thick sphinx
#

look at the attachments to get a better idea of what is going on

narrow estuary
#

sure

#

i think i have an idea

#

your cardestroyed

#

is set to true

#

but carspawned is never set to false again until another attempt

#

So the check in the Touched event handler never passes

#

if timeFlipped >= TIME_TO_DESTROY then
car:Destroy()
carDestroyed = true
carSpawned = false - try adding this
print("RunService: ", "CarDestroyed ",carDestroyed,", CarSpawned ",carSpawned )

thick sphinx
#

all the booleans are set to the correct values before spawning another car, I know this because whenever i walk into the rangePart the second time through I print the boolean values, and they pass the if statement

narrow estuary
#

oh

#

in that case

#

have u checked if ur cloning from ReplicatedStorage.car?

#

or maybe MoveTo maybe silently falls
newCar:MoveTo(part.Parent.HumanoidRootPart.Position + Vector3.new(0, 0, 0))

thick sphinx
#

I am because as you can see the instance variable at the top is referencing the car in replicatedstorage, I am always cloning the car from the replicated storge

thick sphinx
narrow estuary
#

well

#

if ur cloning from replicated storage

#

are u sure the car's PrimaryPart is not set before MoveTo

#

or RunService re-check destroys new car instantly

#

ORRR hear me out Car is destroyed before it becomes visible

thick sphinx
#

ohh ok

#

let me check

#

@narrow estuary can i add you to the game so u can help

narrow estuary
#

yeah

#

i guess

#

martinator9001

thick sphinx
#

ok

quasi pecanBOT
#

studio** You are now Level 5! **studio

thick sphinx
narrow estuary
#

alrigh

quasi pecanBOT
#

studio** You are now Level 2! **studio

narrow estuary
#

alright