Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is wrong with this script?

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

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.