Advertisement
TheDev321

Untitled

Feb 1st, 2023
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. script.Parent.Event.OnServerEvent:Connect(function(Player, mouseCF)
  2.     local SmashAnim = script.Parent.Animations.SmashAnim
  3.     local SmashPlay = Player.Character:WaitForChild('Humanoid'):LoadAnimation(SmashAnim)
  4.     SmashPlay:Play()
  5.    
  6.     local start = CFrame.new(Player.Character:WaitForChild("HumanoidRootPart").Position, mouseCF)
  7.     local goal = start.LookVector * 70
  8.    
  9.     local shardsNum = math.random(8, 15)
  10.     local shardIncrements = 70 / shardsNum
  11.    
  12.     for i = 1, shardsNum do
  13.         local newShard = shard:Clone()
  14.         newShard.Anchored = true
  15.         newShard.CanCollide = false
  16.        
  17.         local x, y, z = math.random(30, 50) / 30 * i, math.random(30, 50) / 30 * i * 2, math.random(30, 50) / 30 * i
  18.         newShard.Size = Vector3.new(0, 0, 0)
  19.         newShard.Orientation = Vector3.new(math.random(-30, 30), math.random(-180, 180), math.random(-30, 30))
  20.        
  21.        
  22.         local pos = Player.Character:WaitForChild("HumanoidRootPart").Position + start.LookVector * (shardIncrements * i)
  23.        
  24.         newShard.Position = Vector3.new(pos.X, mouseCF.Y, pos.Z) --Vector3.new(pos.X, 0, pos.Z)
  25.        
  26.         local newSize = Vector3.new(x, y, z)
  27.         local newPos = newShard.Position + Vector3.new(0, y / 2.5, 0)
  28.        
  29.         local tween = ts:Create(newShard, ti, {Size = newSize, Position = newPos})
  30.    
  31.         newShard.Parent = workspace
  32.        
  33.         tween:Play()
  34.        
  35.         local charactersHit = {}
  36.        
  37.         newShard.Touched:Connect(function(touch)
  38.             if touch.Parent:FindFirstChild("Humanoid") and touch.Parent ~= Player.Character and not charactersHit[touch.Parent] then   
  39.                 charactersHit[touch.Parent] = true
  40.                 touch.Parent.Humanoid:TakeDamage(40)
  41.             end
  42.         end)
  43.        
  44.         coroutine.resume(coroutine.create(function()
  45.             wait(3)
  46.             local reverseTween = ts:Create(newShard, ti, {Size = Vector3.new(0, 0, 0), Position = Vector3.new(pos.X, 0, pos.Z)})
  47.             reverseTween:Play()
  48.            
  49.             reverseTween.Completed:Wait()
  50.             newShard:Destroy()
  51.         end))
  52.        
  53.         wait(math.random(1, 100)/1000)
  54.     end
  55. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement