How would i make this forcefield affect other people but not me?
I am currently trying to make a Force Field at the moment and it all works fine, i'm still working on pretty much everything about this, but there is one thing that is stumping me. I can't get my force field to affect other people but not me. Basically, if anybody touches the forcefield, or goes inside of it, they take damage, but if i touch it, i don't want to take damage. I'm not too familiar with local players as apposed to any other character. The function of the hitting a character is at the bottom of the code. I tried to make a little bit of code, but i never could quite figure it out, please help me, thanks in advance! :)
01 | local tool = script.Parent |
07 | local character = game:GetService( 'Players' ).LocalPlayer |
08 | local player = character.Character or character.CharacterAdded:wait() |
10 | tool.Equipped:connect( function (mouse) |
11 | mouse.KeyDown:connect( function (key) |
12 | if key = = "q" and debounce = = false then |
15 | local ForceField = Instance.new( "Part" , player) |
16 | ForceField.BrickColor = BrickColor.new( "Deep blue" ) |
17 | ForceField.Transparency = 0.7 |
18 | ForceField.CanCollide = false |
19 | ForceField.Anchored = true |
20 | ForceField.Shape = Enum.PartType.Ball |
21 | ForceField.Size = Vector 3. new( 25 , 25 , 25 ) |
22 | ForceField.BottomSurface = Enum.SurfaceType.Smooth |
23 | ForceField.TopSurface = Enum.SurfaceType.Smooth |
24 | ForceField.Position = player.Torso.Position |
25 | ForceField.Parent = game.Workspace |
26 | ForceField.Touched:connect( function (hit) |
27 | local anyplayer = game:GetService( 'Players' ) |