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
6 years ago

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

01game.Players.PlayerAdded:connect(function(player)
02     local Character = player.Character or player.CharacterAdded:wait()
03     Character.Head.Transparency = 1
04     Character.UpperTorso.Transparency = .9
05     Character.LowerTorso.Transparency = .9
06     Character.LeftUpperArm.Transparency = .9
07     Character.LeftLowerArm.Transparency = .9
08     Character.LeftHand.Transparency = .9
09     Character.RightUpperArm.Transparency = .9
10     Character.RightLowerArm.Transparency = .9
11     Character.RightHand.Transparency = .9
12     Character.LeftUpperLeg.Transparency = .9
13     Character.LeftLowerLeg.Transparency = .9
14     Character.LeftFoot.Transparency = .9
15     Character.RightUpperLeg.Transparency = .9
16     Character.RightLowerLeg.Transparency = .9
17     Character.RightFoot.Transparency = .9
18end)
0
for loops needed tonyv537 95 — 6y
0
.9 is not a thing i think its 0.9 tacotown2 119 — 6y
0
.9 is a thing... why wouldn't it be a thing??? Zripple 18 — 6y
0
loops would lag my game Zripple 18 — 6y

1 answer

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

Replace your code with this code:

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

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).

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

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

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

Answer this question