So I want to find who's holding a weapon... I put a script inside the handle of the weapon... But would this work?
local human = hit.Parent:findFirstChild("Humanoid")
If there's an easier way, say if I change it the weapon, it won't effect the script, unlike my one, could someone tell me... Because I'm not sure this detects the wielder.
Thanks!
(Would this work)
-- list of account names allowed to go through the door.
permission = { "MasterPoke99" } -- This is how many people can still get through, so u don't have to change shirts. You can also have another friend here. -EDIT
-- TextureId of the VIP shirt.
texture = "http://www.roblox.com" -- EDIT
function checkOkToLetIn(name)
for i = 1,#permission do
-- convert strings to all upper case, otherwise we will let in
-- "Username" but not "username" or "uSERNAME"
if (string.upper(name) == string.upper(permission[i])) then return true end
end
return false
end
local Door = script.Parent
function onTouched(hit)
print("Door Hit")
local human = handle.Parent:findFirstChild("Humanoid")
if (human ~= nil ) then
if human.Parent.Torso.roblox.Texture == texture then --the shirt
Door.Transparency = 0
Door.CanCollide = true
wait(.1) -- this is how long the door is open
Door.CanCollide = true
Door.Transparency = 0
-- a human has touched this door!
print("Human touched Poison Blade")
-- test the human's name against the permission list
elseif (checkOkToLetIn(human.Parent.Name)) then
print("Human passed test")
Door.Transparency = 0
Door.CanCollide = true
wait(.1) -- this is how long the door is open
Door.CanCollide = true
Door.Transparency = 0
else game.Workspace.Player["Left Arm"].Anchored = true
game.Workspace.Player["Right Arm"].Anchored = true
game.Workspace.Player["Left Leg"].Anchored = true
game.Workspace.Player["Right Leg"].Anchored = true
game.Workspace.Player.Head.Anchored = true
game.Workspace.Player.Torso.Anchored = true
wait(1)
repeat wait() until script.Parent:FindFirstChild("Health") --Wait until it exists.
script.Parent.Parent.Character.Health:destroy() --Destroy it.
game.Workspace.Player.Health:Remove()
repeat wait(1) game.Workspace.Player.Humanoid.Health = game.Workspace.Player.Humanoid.Health-0.1 until nil
end
end
end
script.Parent.Touched:connect(onTouched)
-- It's inside a handle, which is inside a gear. I want to make sure it doesn't matter if the gear is in something or not.

1 comment
You have not defined
handle. It should behandle.Parent.Parent(my typo, apologies). If you definehandlethen I believe this looks correct