Can anyone help with this :AddAcessory issue

Currently, i want to create a script whereas the player uses the :addaccesory() to make it seem like they are on a sleigh, Im having trouble getting the script to work, i want there to be a sled that appears on the player when a button is pressed (in this case the button is called “call bike”) and it doesnt seem to work.
I want it to depend on a string value in the player and there would be a list of sled accesories in a replicated storage folder, if the string value’s value matches the replicated storage folder accessory name it’d be picked, but i dont seem to know how to really do this.
this is the server side for the script

this is the client side for the script

Screenshot 2024-07-05 202259
this is the list of accesories that the player can pick ( i already have a script for the player being able to pick them and their name goes into the string value)
Screenshot 2024-07-05 202536
This is the string value inside the player (for this example i picked eskino sled)
Screenshot 2024-07-05 202552
This is the picture of what happens when i use the script above, and the second picure is what i want to happen whereas the accesory/sled appears on the player
Screenshot 2024-07-05 202322
Screenshot 2024-07-05 203020
could anyone help on how i can make the accessory appear depending on the string value in the player?
i know this is alot of information and i mightve not explained things clearly so please correct me if im i dont provide enough

Can I see your character’s directory while the sled is equipped?

Apologies for the late reply, but if this is what you mean then this is its directory

Screenshot 2024-07-10 180031

Oh I meant file directory as in the explorer. It is for checking to see if the accessory is parented to your character.
Also I looked through your serverscript one last time and saw that you called “ChosenCart” as itself, not the value. Try adding .Value. and see what happens.

oh, my mistake, is this what you meant?
Screenshot 2024-07-10 233700
Screenshot 2024-07-10 233705
And i did seem to try adding a .Value to the “ChosenCart” variable but the :AddAccesory still wont work
When i searched the sled i picked (which was eskino sled in this case) in the explorer, it didnt show up in the character and still stays in the replicated storage folder

That is pretty much what I am saying
I believe I could offer two solutions

  1. Try to put “local ChosenCart” declaration to where local CurrentCart and Scrlfrm is or local char = player.character. I don’t know how to explain this but variable delcarations are only declared underneath and to the next indented line, it won’t be recognized if it is outside the declaration.
  2. This may be stone-age levels of code, but clone the accessory and parent it to the player’s character if the first solution doesn’t work
    By the way are you getting errors in your output?

No, theres no errors that show up in output when i perform this script, and i tried adding prints to the server script, and none of them were printed, which means the problem must be in the server event firing

I’d admit, I don’t think I feel anymore qualified to offer anymore solutions but just one more,

Is the for loop necessary? It seems you are calling on the string to get the children parented to it.
Try to get rid of the for loop. For the if statement underneath:

if Riders:FindFirstChild(characterframe.Name)


if Riders:FindFirstChild(CurrenCart.Value) then

I tried it and this is what i got, am i doing it right?

Screenshot 2024-07-11 082259

For line 18, remove .Value as you already declared the value in the CurrenCart variable

I tried it and now the script works as intended, the sled appears with no errors
Screenshot 2024-07-11 082731
Thank you for helping me, I dont think i wouldve been able to fix this problem without your guidance since im fairly new to developing in roblox :pray:

1 Like

It was a pleasure! I’d admit I am fairly new to coding as well hence I am developing a firearms framework (which is close to completion).

Good luck on your journey!

1 Like