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! :)
local tool = script.Parent
Something = not nil
local debounce = false
local character = game:GetService('Players').LocalPlayer
local player = character.Character or character.CharacterAdded:wait()
tool.Equipped:connect(function(mouse)
mouse.KeyDown:connect(function(key)
if key == "q" and debounce == false then
debounce = true
print("ForceField")
local ForceField = Instance.new("Part", player)
ForceField.BrickColor = BrickColor.new("Deep blue")
ForceField.Transparency = 0.7
ForceField.CanCollide = false
ForceField.Anchored = true
ForceField.Shape = Enum.PartType.Ball
ForceField.Size = Vector3.new(25,25,25)
ForceField.BottomSurface = Enum.SurfaceType.Smooth
ForceField.TopSurface = Enum.SurfaceType.Smooth
ForceField.Position = player.Torso.Position
ForceField.Parent = game.Workspace
ForceField.Touched:connect(function(hit)
local anyplayer = game:GetService('Players')
local localplayer =
if
anyplayer then
print ("firing")
elseif
end
end)
wait(2)
ForceField:remove()
debounce = false
end
end)
end)

2 comments
Magnitude.
Couldn't you just use an if statement to check if the player who touched the force field's name is the same as yours?