Basically I have made a script which makes a ball appear and expand when a player presses Q. When I included a damage script, the balls goes ontop of the player.
GIF of being broken: https://gyazo.com/c53b781adf9c40d213f47883df504937
GIF of working: https://gyazo.com/c53b781adf9c40d213f47883df504937
Heres the entire code:
plr = game.Players.LocalPlayer Enabled = script.Parent.Parent:WaitForChild("Available") En = true UserInput = game:GetService("UserInputService") Mouse = plr:GetMouse() runSerive = game:GetService("RunService") Skills = {"EarthBlock1","EarthBlock2","EarthBlock3","Fire"} UserInput.InputBegan:connect(function(Input,gameProcessed) if Input.KeyCode == Enum.KeyCode.Q then--and Enabled.Value == true --and En == true and plr:WaitForChild("Data").Level.Value >= 5 and plr.Data.Element.Value == "Earth" and gameProcessed == false then En = false Enabled.Value = false --plr.Character.Humanoid.WalkSpeed = 0 local animTrack = plr.Character.Humanoid:LoadAnimation(script.Animation1) animTrack:Play() for i = 1,5 do local x = Instance.new("Part") local Ring = script:WaitForChild("Ring"):Clone() Ring.Parent = game.Workspace Ring.CFrame = plr.Character.LowerTorso.CFrame * CFrame.new(0,-1,0) * CFrame.Angles(math.random(-360,360),0,math.random(-360,360)) Ring.CanCollide = false Ring.Anchored = true local Ring2 = script:WaitForChild("Ring"):Clone() Ring2.Parent = game.Workspace Ring2.Mesh.Scale = Vector3.new(2,2,2) Ring2.CFrame = plr.Character.LowerTorso.CFrame * CFrame.new(0,-1,0) * CFrame.Angles(math.random(-360,360),0,math.random(-360,360)) Ring2.CanCollide = false Ring2.Anchored = true x.CanCollide = false x.Anchored = true x.Size = Vector3.new(1,1,1) x.CFrame = plr.Character.LowerTorso.CFrame - Vector3.new(0,3,0) x.Transparency = 0.1 x.TopSurface = "Smooth" x.BottomSurface = "Smooth" x.BrickColor = BrickColor.new("Ghost grey") local mesh = Instance.new("SpecialMesh",x) mesh.MeshType = Enum.MeshType.Sphere x.Parent = game.Workspace AlreadyHit = false x.Touched:connect(function(Hit) print(Hit.Name) if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Name ~= plr.Name and AlreadyHit == false then print("2") AlreadyHit = true Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20) elseif Hit.Parent:FindFirstChild("Humanoid") ~= true then print("3") for i = 1,table.getn(Skills) do if Hit.Name == Skills[i] then Hit.BodyVelocity.Velocity = Hit.BodyVelocity.Velocity + Vector3.new(180,0,0) print("4") end end end end) for i = 1,20 do game:GetService("RunService").Heartbeat:wait() Ring.Mesh.Scale = Ring.Mesh.Scale + Vector3.new(2,2,2) Ring.Transparency = Ring.Transparency + 0.025 Ring2.Mesh.Scale = Ring.Mesh.Scale + Vector3.new(2,2,2) Ring2.Transparency = Ring2.Transparency + 0.025 x.Size = x.Size + Vector3.new(2,2,2) x.Transparency = x.Transparency + 0.025 end Ring:Destroy() Ring2:Destroy() x:Destroy() end end end)
When I add this section in the code breaks
AlreadyHit = false x.Touched:connect(function(Hit) print(Hit.Name) if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Name ~= plr.Name and AlreadyHit == false then print("2") AlreadyHit = true Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(2 + plr.Data.BendingLevel.Value/10) elseif Hit.Parent:FindFirstChild("Humanoid") ~= true then print("3") for i = 1,table.getn(Skills) do if Hit.Name == Skills[i] then Hit.BodyVelocity.Velocity = Hit.BodyVelocity.Velocity + Vector3.new(180,0,0) print("4") end end end end)
I've got no clue why. I've spent hours and hours on this but I've got no clue.
This is cause you used Vector3 on the position and size of a part, you need to use CFrame.