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.
01 | wait( 5 ) |
02 | player = game.Players.LocalPlayer |
03 | mouse = player:GetMouse() |
04 | safe = game.Workspace.Player -- i used safe as the vairable to distingush between who gets hurt and who doesn't |
05 |
06 | print ( "GO" ) |
07 |
08 | detectionPad = Instance.new( "Part" ,player.Character) |
09 | detectionPad.Anchored = true |
10 | detectionPad.CanCollide = false |
11 | detectionPad.BrickColor = BrickColor.new( "Really blue" ) |
12 | detectionPad.Transparency = . 4 |
13 | detectionPad.FormFactor = Enum.FormFactor.Custom |
14 | detectionPad.Size = Vector 3. new( 10 , 0.5 , 10 ) |
15 | detectionPad.CFrame = detectionPad.CFrame*CFrame.Angles( 1 , 0 , 0 ) |
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.
01 | permission = { "Player" } |
02 |
03 | function checkOkToLetIn(name) |
04 | for i = 1 ,#permission do |
05 | if (string.upper(name) = = string.upper(permission [ i ] )) then return true end |
06 | end |
07 | return false |
08 | end |
09 |
10 | local Door = script.Parent |
11 |
12 | function onTouched(hit) |
13 | local human = hit.Parent:findFirstChild( "Humanoid" ) |
14 | if (human ~ = nil ) then |
15 | if (checkOkToLetIn(human.Parent.Name)) then |
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:
1 | local part = Instance.new( "Part" ) |
2 | part.Parent = game.Workspace |
3 | local clone = part:Clone() |
4 | clone.Parent = game.Workspace |