Oh so I am new to scripting and I need to know how to refer to the player who touched it and do it to him.
local D = Workspace.D function onTouch(part) game.Workspace.Player1.Head:Destroy() end D.Touched:connect(onTouch)
And one more thing what do you refer to as Right or left arm in roblox scripting
I *believe * you refer to person who touched it as the parent. So in your case:
game.Workspace.PARTNAMEHERE.Parent.Head:Destroy()
Also try the FindFirstChild method. So:
arm = game.Workspace.PARTNAMEHERE.Parent:FindFirstChild("Right Arm") arm:Destroy()
I hope this works
To refer to a name with a space, we use square brackets ([
and ]
) to index instead of a dot (.
), and then the string of the name:
person["Name With Space"] -- vs person.NameWithoutSpace
The part
that touches us can be a leg or an arm or the head or torso. Those parts make up what a player's Character. Once we get the Character, we can grab the corresponding Player.
local D = Workspace.D function onTouch(part) game.Workspace.Player1.Head:Destroy() character = part.Character if character then player = game.Players:GetPlayerFromCharacter( character ) if player then -- It is a player -- (as opposed to some other random object hitting it) character.Head:Destroy() end end end D.Touched:connect(onTouch)