With some help from other people, i have been successful in creating a tool that spawns a bubble around your character that damages other people. I'm now getting frustrated when this doesn't work online. It works somewhat, but there is one major flaw in the coding and idk where considering there is no errors. WHenever i put this to online (Or when i launch a server with two players for this matter) the script goes exactly as planned, except when the person dies, if you try to use the tool again, the bubble gets placed near the dead body and not near the actual person if that makes sense. The bubble doesn't want to go to the CFrame of the player's current torso, instead, it goes to the torso of the dead torso and idk why. This only happens when i launch a server or click play.
The scripts being shown is a local script in a tool
local tool = script.Parent
local health = false
humanoid = 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.CFrame = CFrame.new(player.Torso.Position + Vector3.new(0,0,0))
ForceField.Parent = game.Workspace
ForceField.Touched:connect(function(hit)
local humanoid = hit.Parent:findFirstChild("Humanoid")
if not hit:IsDescendantOf(player) and health == false and humanoid then
health = true
humanoid.Health = humanoid.Health -3
print ("DEATH TO THE HOOOOMANNSSSS")
health = false
else
print("Hi Me ;)")
wait(.1)
return
end
end)
wait(2)
ForceField:remove()
debounce = false
end
end)
end)

1 comment
Maybe you should try making the player variable after line 14.