Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I repeat a script after I respawn or die?

Asked by 5 years ago

So basically I was gonna add in a first person view of your avatar in first person like torso, legs and arms but whenever I die it resets it. I was thinking if any of the script helpers or professional scripters could help me.

--[[ Notes:
Transparency Modifier is what is the end result when "zooming in", it can be changed to whatever you like.

Camera Offset is changed to allow the player to see at lower angles without clipping the view with the torso.
This may or maynot effect certian tools if they change the players camera position IE crouching or crawling.

Use:
Place into StarterPlayer.StarterChacterScripts

--]]

local character = (game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait())

game:GetService("RunService").RenderStepped:connect(function() if (character:FindFirstChild("Right Arm") and character:FindFirstChild("Left Arm")) then

    character:FindFirstChild("Right Arm").LocalTransparencyModifier = 0

    character:FindFirstChild("Left Arm").LocalTransparencyModifier = 0

    character:FindFirstChild("Right Leg").LocalTransparencyModifier = 0

    character:FindFirstChild("Left Leg").LocalTransparencyModifier = 0

    character:FindFirstChild("Torso").LocalTransparencyModifier = 0 

    character:FindFirstChild("Humanoid").CameraOffset = Vector3.new(0,0,-1)
end

end)

0
Roblox does not provide an event for when the character has respawned, but you do have the died event, which you can time with the time that it takes to respawn to apply your required changes. Check events section of [this article.](https://developer.roblox.com/en-us/api-reference/class/Humanoid) Ashley_Phantom 372 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
game:GetService("Players").PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(character, Player)
        character:FindFirstChild("Right Arm").LocalTransparencyModifier = 0
        character:FindFirstChild("Left Arm").LocalTransparencyModifier = 0
        character:FindFirstChild("Right Leg").LocalTransparencyModifier = 0
        character:FindFirstChild("Left Leg").LocalTransparencyModifier = 0
        character:FindFirstChild("Torso").LocalTransparencyModifier = 0
        character:FindFirstChild("Humanoid").CameraOffset = Vector3.new(0,0,-1)
        character:WaitForChild("Humanoid").Died:Connect(function()
            character:FindFirstChild("Right Arm").LocalTransparencyModifier = 0
            character:FindFirstChild("Left Arm").LocalTransparencyModifier = 0
            character:FindFirstChild("Right Leg").LocalTransparencyModifier = 0
            character:FindFirstChild("Left Leg").LocalTransparencyModifier = 0
            character:FindFirstChild("Torso").LocalTransparencyModifier = 0
            character:FindFirstChild("Humanoid").CameraOffset = Vector3.new(0,0,-1)
        end)
    end)
end)

Disgusting, but works.

Ad

Answer this question