Why does it come out as nil?

I created a script where as a script gets put in the players character with the click of a button then after that i want the script that was inserted to be deleted out the character but i get this error


this is the server script for it

this is the replicated storage folder one of the scripts come from
Screenshot 2024-08-11 172230

1 Like

Hey! Please give us more context to how your code works and how it should work. There isn’t much we can understand from a remote event destroying something within a character which we don’t know how its setup, used, etc. Thank you!

Try to print ability and show what it printed

I think when you clone something and don’t parent it, it won’t be available anywhere in the player character, so :FindFirstChild() returns nil since it isn’t there

It’s looking for the chosen ability’s name in the character, not the actual ability.

Sorry for the late response, but this is how the script works
theres a button at the bottom where the player can spawn in an accessory which is supposed to be a type of vehicle thats spawned, each time the button is pressed and the vehicle is present in the players character it is supposed to despawn.
theres a selection of vehicles you can pick from and each have their own ability script which goes inside the character script with the accessory



this is the client script where it takes the button thats pressed then fires to the server which is the server script i showed before, the problem im having is the that was inserted with the accesory is not being deleted as well
for example this is one of the scripts from the selectable vehicles, whenever i despawn my vehicle and the vehicle gets destroyed, the script doesnt get destroyed and it stays
Screenshot 2024-08-11 213807

Screenshot 2024-08-11 213738
this is what i got after i printed the ability variable

Can you show what is inside the character?

Screenshot 2024-08-11 215433
this is whats inside the character, the red bike is the accessory which is able to get deleted when the player presses the button while its inside the character, but pedal pummel is its script and it doesnt get deleted upon the button being clicked after it already being in the player

Are you sure ability is the pedal pummel?

It has to be, since it wouldn’t have been able to be inserted inside the player if it weren’t right?

Hm, try using char:WaitForChild(ChosenAbility.Name) instead of char:FindFirstChild(ChosenAbility.Name)


i get this infinite yield error

Maybe it’s because the pedal pummel is only visible on the client.

So does that mean server scripts cant destroy a local script?

No, it means that server scripts can’t destroy an object that is placed on the client.

So ill have to destroy it through a remote event to the client so that client can destroy the client script inside the players character?

Yeah. Exactly thaaaaaaaaaaaaat

ok, ill try making a remote event to delete the script :+1:

1 Like