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

Why do my arms disappear when I reset?

Asked by 9 years ago

I made a script to show your arms while in first person. Why do they disappear when I reset? Here is the script:

01local self,player = script.Parent,game.Players.LocalPlayer
02 
03local char = player.Character or player.CharacterAdded:wait()
04 
05 local humanoid = char:WaitForChild("Humanoid")
06 
07function antiTrans(part)
08 
09    if part and part:IsA("BasePart") and( part.Name=="Left Arm" or part.Name=="Right Arm") then
10 
11        part.LocalTransparencyModifier = part.Transparency
12 
13        part.Changed:connect(function (property)  
14 
15            part.LocalTransparencyModifier = part.Transparency
View all 29 lines...

2 answers

Log in to vote
2
Answered by 9 years ago

So basically, you need to add some more connections and event listeners in your script. To do this your going to have convert from a LocalScript to a ServerScript(or regular script in broad terms.)

The main reason it only works once, is because you don't have an event for when the character respawns. This can be done by using Character Added. This fires the even every time character respawn. To use this event, you need to redefine player in a different way because this can't be used in local scripts. So essentially this how it should be.

01game.Players.PlayerAdded:connect(function(player)
02    player.CharacterAdded:connect(function(char)
03            local humanoid = char:WaitForChild("Humanoid")
04        for i,part in pairs(char:GetChildren()) do
05        if part and part:IsA("BasePart") and( part.Name=="Left Arm" or part.Name=="Right Arm") then
06             part.LocalTransparencyModifier = part.Transparency
07                      part.Changed:connect(function(property)
08                        part.LocalTransparencyModifier = part.Transparency
09 
10                end)
11            end
12        end
13    end)
14end)
Ad
Log in to vote
1
Answered by 9 years ago

qwertyuiopasdfghjklzxcvbnm1234567890

Answer this question