Welding in a server script

im trying to make a boombox that can be mounted to the players back. how can i weld the radio to the players torso in a server script


Create.a weld with Instance.new("Weld"), parent it to the character, unanchor it and change Part0 to a part in the radio, Part1 to be the torso

Edit: Make sure to do this every time CharacterAdded is fired (In case the player dies)

1 Like

I wrote this code but it doesn’t work. Any solution?


1 Like

Can you show me the explorer tab (including character + weld) along with where you fired the function, where the script is etc?

It works on the client, here is the current code.

I fire the function when you unequip the tool.

A good thing to do is to create a clone of the handle instead of directly putting the original in the character.
(Does it run? any errors? )

Tried debugging it with a print after the last line. No prints and no errors

Meaning that this function never runs. This is due to the fact that when you run ‘onUnequip’, the player is already obviously in the game (since they. unequpiped the tool) so instead, try finding the localplayer with game.Players.Localplayer, and using a remoteevent to make sure it is server-sided

This is when the event fires in the server script

this is the local script

Yea well the problem is, PlayerAdded runs when a new player is added to the game. If the player unequips the tool, that will NEVER run! (for that player, at least) since the player is already in the game in order to unequip the tool .-.

1 Like

Yep! This is the problem with the code above. When you want to get a player when the tool is equipped, you can do it like this:

  • Get the tool’s Parent. This is the character
  • Use Player.GetPlayerFromCharacter to get the player from the character
  • Done! Note this only works when the tool is equipped. When the tool isn’t equipped, tool.Parent gets the backpack, and tool.Parent.Parent gets the player