Advertisement
HowToRoblox

IceCreator

Jul 17th, 2021
2,815
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. local re = game.ReplicatedStorage:WaitForChild("IceMagicActivated")
  2.  
  3.  
  4. local plrsCoolingDown = {}
  5.  
  6.  
  7. local shard = script:WaitForChild("IceShard")
  8.  
  9.  
  10. local ts = game:GetService("TweenService")
  11.  
  12. local ti = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
  13.  
  14.  
  15.  
  16. re.OnServerEvent:Connect(function(plr, mouseCF)
  17.    
  18.    
  19.     if plrsCoolingDown[plr] then return end
  20.    
  21.     plrsCoolingDown[plr] = true
  22.    
  23.    
  24.     local start = CFrame.new(plr.Character.HumanoidRootPart.Position, mouseCF.Position)
  25.    
  26.     local goal = start.LookVector * 70
  27.    
  28.    
  29.     local shardsNum = math.random(8, 15)
  30.    
  31.     local shardIncrements = 70 / shardsNum
  32.    
  33.  
  34.    
  35.     for i = 1, shardsNum do
  36.        
  37.        
  38.         local newShard = shard:Clone()
  39.         newShard.Anchored = true
  40.         newShard.CanCollide = false
  41.        
  42.        
  43.         local x, y, z = math.random(30, 50)/30 * i, math.random(30, 50)/30 * i * 2, math.random(30, 50)/30 * i
  44.        
  45.         newShard.Size = Vector3.new(0, 0, 0)
  46.        
  47.         newShard.Orientation = Vector3.new(math.random(-30, 30), math.random(-180, 180), math.random(-30, 30))
  48.        
  49.        
  50.         local pos = plr.Character.HumanoidRootPart.Position + start.LookVector * (shardIncrements * i)
  51.        
  52.         newShard.Position = Vector3.new(pos.X, 0, pos.Z)
  53.        
  54.        
  55.         local newSize = Vector3.new(x, y, z)
  56.         local newPos = newShard.Position + Vector3.new(0, y/2.5, 0)
  57.        
  58.         local tween = ts:Create(newShard, ti, {Size = newSize, Position = newPos})
  59.        
  60.        
  61.         newShard.Parent = workspace
  62.        
  63.         tween:Play()
  64.        
  65.        
  66.         local charactersHit = {}
  67.        
  68.         newShard.Touched:Connect(function(touch)
  69.            
  70.            
  71.             if touch.Parent:FindFirstChild("Humanoid") and touch.Parent ~= plr.Character and not charactersHit[touch.Parent] then
  72.                
  73.                 charactersHit[touch.Parent] = true
  74.                
  75.                 touch.Parent.Humanoid:TakeDamage(30)
  76.             end
  77.         end)
  78.        
  79.        
  80.         coroutine.resume(coroutine.create(function()
  81.            
  82.            
  83.             wait(3)
  84.            
  85.            
  86.             local reverseTween = ts:Create(newShard, ti, {Size = Vector3.new(0, 0, 0), Position = Vector3.new(pos.X, 0, pos.Z)})
  87.            
  88.             reverseTween:Play()
  89.            
  90.             reverseTween.Completed:Wait()
  91.             newShard:Destroy()
  92.         end))
  93.        
  94.        
  95.         wait(math.random(1, 100)/1000)
  96.     end
  97.    
  98.    
  99.     plrsCoolingDown[plr] = false
  100. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement