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

How do you get this script to continue to work after i die???

Asked by
Zripple 18
5 years ago

Would an OnTouch help? I don't know how to add that to this. Please Help.

game.Players.PlayerAdded:connect(function(player)
     local Character = player.Character or player.CharacterAdded:wait()
     Character.Head.Transparency = 1
     Character.UpperTorso.Transparency = .9
     Character.LowerTorso.Transparency = .9
     Character.LeftUpperArm.Transparency = .9
     Character.LeftLowerArm.Transparency = .9
     Character.LeftHand.Transparency = .9
     Character.RightUpperArm.Transparency = .9
     Character.RightLowerArm.Transparency = .9
     Character.RightHand.Transparency = .9
     Character.LeftUpperLeg.Transparency = .9
     Character.LeftLowerLeg.Transparency = .9
     Character.LeftFoot.Transparency = .9
     Character.RightUpperLeg.Transparency = .9
     Character.RightLowerLeg.Transparency = .9
     Character.RightFoot.Transparency = .9
end)
0
for loops needed tonyv537 95 — 5y
0
.9 is not a thing i think its 0.9 tacotown2 119 — 5y
0
.9 is a thing... why wouldn't it be a thing??? Zripple 18 — 5y
0
loops would lag my game Zripple 18 — 5y

1 answer

Log in to vote
-1
Answered by
LawlR 182
5 years ago
Edited 5 years ago

Replace your code with this code:

game:GetService("Players").PlayerAdded:Connect(function(player) -- Same as your first line.
    player.CharacterAdded:Connect(function(character) -- The following code will happen every time you spawn.
        -- Your transparency code. Instead of writing out every body part, do this instead:
        for i,v in pairs(character:GetChildren()) do
            if v:IsA("BasePart") and v.Name ~= "Head" then
                v.Transparency = 0.9
            end
        end
        character.Head.Transparency = 1
    end)
end)

Haven't tested, there may be typos.

To answer comments:

@yHasteeD HumanoidRootPart counts as BasePart, and it is invisible by default.

@kingdom5 I said 'instead of writing out every body part' which suggests that this is a way to go through all of the body parts without actually writing them all out. I didn't comment on the rest of it because it basic English. If v is a base part, there's no need to explain that.

@Zripple Yes, it would still work if you used R6 characters. To remove your clothing, you would need to check if 'v' is a clothing instance and if it is, destroy it. There are 3 clothing instances: Shirt, Pants, and ShirtGraphic (T-shirts).

if v:isA("Shirt") or v:IsA("Pants") or v:IsA("ShirtGraphic") then
    v:Destroy()
end

You would want to add that code into the for loop with an elseif.

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        for i,v in pairs(character:GetChildren()) do
            if v:IsA("BasePart") and v.Name ~= "Head" then
                v.Transparency = 0.9
            elseif v:isA("Shirt") or v:IsA("Pants") or v:IsA("ShirtGraphic") then -- Removing clothes.
                v:Destroy()
            end
        end
        character.Head.Transparency = 1
    end)
end)
0
You forgot to use and v.Name ~= "HumanoidRootPart", but if humanoidrootpart is visible you can see a block in the character. yHasteeD 1819 — 5y
0
Can you explain why Zripples code is not working. Replace your code does not explain why it works. User#5423 17 — 5y
0
I changed my character to r6... would this still work? Zripple 18 — 5y
0
@LawlR Is there also a way to change this to remove your clothing? (also to work when you die) Zripple 18 — 5y
0
Edited answer. LawlR 182 — 5y
Ad

Answer this question