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

What is wrong with this script?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I made this script to make a model's parts go invisible and walk-through, but only the head worked?

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then

    wait(.6)
    game.Workspace.noob1.Head.Transparency=1
    game.Workspace.noob1.Head.CanCollide=false
    game.Workspace.noob1.LeftLeg.Transparency=1
    game.Workspace.noob1.LeftLeg.CanCollide=false
    game.Workspace.noob1.Rightleg.Transparency=1
    game.Workspace.noob1.Rightleg.CanCollide=false
    game.Workspace.noob1.Torso.Transparency=1
    game.Workspace.noob1.Torso.CanCollide=false
    game.Workspace.noob1.RARM.Transparency=1
    game.Workspace.noob1.RARM.CanCollide=false
    game.Workspace.noob1.LARM.Transparency=1
    game.Workspace.noob1.LARM.CanCollide=false


end
end

script.Parent.Touched:connect(onTouched)

2 answers

Log in to vote
1
Answered by
HexC3D 830 Moderation Voter
10 years ago
function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then

    wait(.6)
    game.Workspace.noob1.Head.Transparency=1
    game.Workspace.noob1.Head.CanCollide=false
    game.Workspace.noob1["Left Arm"].Transparency=1
      game.Workspace.noob1["Left Leg"].CanCollide=false
    game.Workspace.noob1["Right Leg"].Transparency=1
    game.Workspace.noob1["Right Leg"].CanCollide=false
    game.Workspace.noob1.Torso.Transparency=1
    game.Workspace.noob1.Torso.CanCollide=false 
  -- I don't know what you mean by anything below this
 end
end

script.Parent.Touched:connect(onTouched)

This should work

Ad
Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

It won't let you walk through walls.

script.Parent.Touched:connect(function(hit)
    if hit.Parent then 
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then 
            for i,v in pairs(player.Character:GetChildren()) do 
                if v:IsA("BasePart") then 
                    v.Transparency = 1
                    v.CanCollide = false
                elseif v:isA("Hat") then 
                    v.Handle.Transparency = 1
                end
            end
        end
    end     
end)

Answer this question