Make player body parts appear onTouch brick

I am trying to make a Part where if the player touches it will make a Part inside the StarterCharacter Model appear when it touches the part

I have tried a different code but it does not work so I wrote my own but it says unknow global ‘Player’
Here is the script:

function onTouched()
Player.Character:FindFirstChild(“Left Arm2”).Transparency = 0

end

1 Like
part.Touched:Connect(function(hit)
  local player = game.Players:GetPlayerFromCharacter(hit.Parent) 

  if player then 
      player.Character:FindFirstChild("Left Arm2").Transparency = 0
  end
end)

I got 2 errors when using it:

Error: (7,1) Syntax error: Expected identifier when parsing expression, got ‘)’

Error: (7,1) Syntax error: Expected ‘end’ (to close ‘function’ at line 1), got ; did you forget to close ‘then’ at line 4?

try again I didn’t put an “end” in before

Its not working. Is it because I am using a StarterCharacter In StarterPlayer?

yes that is the problem you can only use .Touched events on ServerScripts

No I Mean like I have my StarterCharacter in StarterPlayer. But the script in on a block not in the character. In the workspace

what? your player character goes in the workspace

Im only using a StarterCharacter because I can add parts attached to it. I dont know how to add a part to a normal player.

show

local pdb = false
local function Touched(Hit)
       if not pdb then
       pdb=true
       local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
       if not Player then return 0 end
       Player.Character["Left Arm2"].Transparency = 0
       wait(0.1)
        pdb = false -- add a debounce because the event fires every millisecond
end
end
script.Parent.Touched:Connect(Touched)

Put in part
(Yes ik it’s poorly formatted)

A debounce is not needed because once the part transparency is 0, setting it to 0 won’t change anything, but it’s still more efficient so it won’t run the function multiple times.

The debounce is there for efficiency, yes

Think you meant game.Players:GetPlayerFromCharacter()

you’re right i’ll fix it now i meant game.Players:GetPlayerFromCharacter

I feel like its easier to not use a StarterCharacter and just Insert the Left Arm2 to the left arm Location when the part is touched. But I dont know how to instert a part on the arms location with the same size as the arm

What the…
Alright fine. I’ll make the neatest code in the world.

print("Code online")
local Part = script.Parent
Part.Touched:Connect(function(Hit)
       print("Part touched")
       local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
       if Player then
             local Arm = Player.Character:FindFirstChild("Left Arm2") or Player.Character:FindFirstChild("Left Arm2 ") or Player.Character:FindFirstChild(" Left Arm2") 
             if Arm then
                    Arm.Transparency = 0 
             else 
                  print("No arm found")
             end
       else
             print("A PLAYER DIDN'T TOUCH THE PART? WHAT THE HECK?")
       end
end)

Tell me if it prints, no need for a yt vid or something like that

No arm Found

Part Touched

All it says

By default there is no part called “Left Arm2”, you are trying to set the transparency of a non existant part to 0