Hello! I have made a water protection bubble that surrounds me and protects me from anyone trying to damage me, but I want to make it so that if anyone tries to enter it kills them, but it will also kill me whenever I try to make it. How do i make it kill everyone when they enter except me?

P.S. I am so sorry if the code is hard to read, I hope you can, I just started scripting 5 days ago..

Water Protection Bubble Thingy Code:

local player = game.Players.LocalPlayer
local character = player.Character
local terrain = game.Workspace.Terrain
local ammo = 1

local x = Instance.new("Part")
	x.Size = Vector3.new(48,48,48)
	x.Transparency = 0.2
	x.Shape = "Ball"
	x.CanCollide = false
	x.Anchored = true
	x.BrickColor = BrickColor.new("Electric blue")
	x.TopSurface = "Smooth"
	x.BottomSurface = "Smooth"
	
local p = Instance.new("ParticleEmitter")
local f = Instance.new("ForceField")
local s = Instance.new("Smoke")
local sl = Instance.new("SurfaceLight")
local sp = Instance.new("Sparkles")
local color1 = Color3.new(121, 244, 255)
local color2 = Color3.new(226, 0, 255)

	p.Parent = x
	p.Color = ColorSequence.new(color1, color2)
	p.Rate = 250
	p.Speed = NumberRange.new(25)
	p.Size = NumberSequence.new(5)
	p.LightEmission = 100
	p.VelocitySpread = 808080
	
		s.Parent = x
		s.Color = Color3.new(75, 255, 234)
			sl.Parent = x
			sl.Range = 60
				sp.Parent = x
				sp.SparkleColor = Color3.new(144, 25, 255)	
						f.Parent = x
	
	game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.Q then

	
local animation = Instance.new("Animation")
local humanoid = script.Parent:WaitForChild('Humanoid')			
				animation.AnimationId = "http://www.roblox.com/asset/?id=855830361"
				humanoid:LoadAnimation(animation):Play()
					wait(1)
	if ammo == 1 then
		ammo = 0
local clx = x:Clone()
local clf = f:Clone()
	clx.Parent = game.Workspace
	clx.CFrame = character.UpperTorso.CFrame * CFrame.new(0,0,0)
	clf.Parent = clx
		game.Debris:AddItem(clx, 10)
		
		wait(20)
		ammo = 1
		end
	end
end) 

6 comments

0

I already know about that, but since the Part is surrounding me and since I am in it, it counts me as touching it and kills me as well. I have tried using that, and I have tried looking for answers on different websites, but nothing helped. I am sorry if this question wasnt good :/

0

You would check if the player's name matches to yours, via retrieving the player and comparing his and your names.

0

Ty! Btw, I am so thankful! Sorry again for my question :/

0

Np. ;)