Basically what the title says i can't figure out how to do this. How would i make the part hurt others but not hurt me when i touch it, i tried this script but it doesn't work.
wait(5) player = game.Players.LocalPlayer mouse = player:GetMouse() safe = game.Workspace.Player -- i used safe as the vairable to distingush between who gets hurt and who doesn't print("GO") detectionPad = Instance.new("Part",player.Character) detectionPad.Anchored = true detectionPad.CanCollide = false detectionPad.BrickColor = BrickColor.new("Really blue") detectionPad.Transparency = .4 detectionPad.FormFactor = Enum.FormFactor.Custom detectionPad.Size = Vector3.new(10, 0.5, 10) detectionPad.CFrame = detectionPad.CFrame*CFrame.Angles(1,0,0) mesh = Instance.new("CylinderMesh",detectionPad) while true do wait() detectionPad.CFrame = player.Character.Torso.CFrame detectionPad.CFrame = detectionPad.CFrame *CFrame.new(0,-3.1,0) if(player.Character.Torso.Position - detectionPad.Position).magnitude <= 5 then if not safe then print("Death") --not going adding the killing part yet end end end
I'm not sure if you can do that with just one script, but if you are willing to have two scripts then do this.
permission = {"Player"} function checkOkToLetIn(name) for i = 1,#permission do if (string.upper(name) == string.upper(permission[i])) then return true end end return false end local Door = script.Parent function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil ) then if (checkOkToLetIn(human.Parent.Name)) then wait(4) else human.Health= 0 end end end script.Parent.Touched:connect(onTouched)
Put this script as a child of your script and disable this script, modify your script to copy this script then past it into the brick and enable it (enabling is a behavior property). Here is an example of how to clone something:
local part = Instance.new("Part") part.Parent = game.Workspace local clone = part:Clone() clone.Parent = game.Workspace