Hi, soutpansa.
To fix your problem, you need to make a function that updates your character and torso variable each time the player respawns.
You need to do this because, when the player respawns, your torso variable, which is now the player's old torso, no longer has the "RightShoulder" weld and is now just a useless part.
However, your script doesn't know that the torso variable is no longer the torso in the player's new body. This is why you need to update your torso variable to your player's new body.
You need to also update your character variable to your player's new body or you would get the player's old torso.
Here is the character updating function I personally use:
01 | local Player = game.Players.LocalPlayer |
02 | local UserInput = game:GetService( "UserInputService" ) |
07 | UserInput.InputBegan:connect( function (key) |
08 | if key.KeyCode = = Enum.KeyCode.Q then |
09 | print (game.Players:GetPlayerFromCharacter(Character).Name) |
15 | local function loadCharacter(char) |
17 | Torso = Character:WaitForChild( "Torso" ) |
20 | if Player.Character then |
21 | loadCharacter(Player.Character) |
24 | Player.CharacterAdded:connect(loadCharacter) |
The "loadCharacter" function has a paramater called char.
It is updated to the player's character each time the player respawns.
In the function, we assign the Character variable to the "char" parameter.
Then, we assign the Torso variable to the Character's torso.
To add my function to your code, delete all your character and torso variables.
Now, create two variables in a global scope. (I personally make them the last variables in the global scope.)
1 | local Player = game.Players.LocalPlayer |
2 | local mouse = Player:GetMouse() |
6 | local Run = game:GetService( "RunService" ) |
After you created your variables, make your loadCharacter function.
Make sure to name your parameter something different from your global character variable.
01 | local Player = game.Players.LocalPlayer |
02 | local mouse = Player:GetMouse() |
06 | local Run = game:GetService( "RunService" ) |
11 | local function loadCharacter(character) |
13 | torso = char:WaitForChild( "Torso" ) |
Almost done. You have to put your function into action.
I'm not sure why, but I always put this code at the end of my script.
Feel free to mess around with the position.
01 | local Player = game.Players.LocalPlayer |
02 | local mouse = Player:GetMouse() |
06 | local Run = game:GetService( "RunService" ) |
13 | local function loadCharacter(character) |
15 | torso = char:WaitForChild( "Torso" ) |
18 | if Player.Character then |
19 | loadCharacter(Player.Character) |
22 | Player.CharacterAdded:connect(loadCharacter) |
Finally, code on with your script normally. You don't have to make new character or
torso variables in your Jojo Sendo Hamon function thing.
01 | local Player = game.Players.LocalPlayer |
02 | local mouse = Player:GetMouse() |
06 | local Run = game:GetService( "RunService" ) |
11 | local function onKeyDown(key) |
12 | local Key = key:lower() |
14 | if Key = = "z" and tick()-lastUse > 20 then |
17 | local rarm = game.ReplicatedStorage.Hamon.RArm:Clone() |
18 | local RightShoulder = torso [ "Right Shoulder" ] |
20 | local a = Instance.new( "Sound" ) |
27 | local rarmweld = Instance.new( "Weld" ) |
28 | rarmweld.Parent = rarm |
29 | rarmweld.Part 0 = rarmweld.Parent |
30 | rarmweld.Part 1 = char:findFirstChild( "Right Arm" ) |
31 | rarmweld.C 1 = CFrame.new( 0 , 0 , 0 ) |
35 | RightShoulder.C 0 = RightShoulder.C 0 *CFrame.Angles( 0 , 0 , 1.6 ) |
36 | game:GetService( "Chat" ):Chat(char.Head, "Sendo Hamon Overdrive!" ) |
38 | RightShoulder.C 0 = RightShoulder.C 0 *CFrame.Angles( 0 , 0 , - 1.6 ) |
39 | Run.Stepped:wait( 0.01 ) |
44 | mouse.KeyDown:connect(onKeyDown) |
46 | local function loadCharacter(character) |
48 | torso = char:WaitForChild( "Torso" ) |
51 | if Player.Character then |
52 | loadCharacter(Player.Character) |
55 | Player.CharacterAdded:connect(loadCharacter) |