Guest User

Untitled

a guest
Feb 23rd, 2020
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. --Local Script
  2. local UIS = game:GetService("UserInputService")
  3.  
  4. local mouse = game.Players.LocalPlayer:GetMouse()
  5. local debounce = false
  6. local player = game.Players.LocalPlayer
  7. local character = player.Character or player.CharacterAdded:Wait()
  8. local humanoid = character:WaitForChild("Humanoid")
  9.  
  10. --Animation--
  11. local animInstance = Instance.new("Animation")
  12. animInstance.AnimationId = "rbxassetid://4586797999"
  13. local FireBallAnim = humanoid:LoadAnimation(animInstance)
  14.  
  15. --Key Code--
  16. UIS.InputBegan:Connect(function(Key, processed)
  17. if processed or debounce then return end
  18. debounce = true
  19. if Key.UserInputType == Enum.UserInputType.Keyboard then
  20. if Key.KeyCode == Enum.KeyCode.Z then
  21. FireBallAnim:Play()
  22. game.ReplicatedStorage.Events.SkillActivation1:FireServer(mouse.Hit.Position)
  23. end
  24. end
  25. wait(1)
  26. debounce = false
  27. end)
  28.  
  29. --Server Script Service
  30. game.ReplicatedStorage.Events.SkillActivation1.OnServerEvent:Connect(function(player, mousePos)
  31. local effects = game.ReplicatedStorage.Effects
  32. local fireBall = effects.MagicSkill:Clone()
  33. local explosion = effects.Explosion:Clone()
  34. local character = player.Character
  35.  
  36. --Fireball--
  37. fireBall.Position = character.RightHand.Position
  38. fireBall.Parent = workspace
  39.  
  40. --Weld--
  41. local weld = Instance.new("WeldConstraint", fireBall)
  42. weld.Part0 = fireBall
  43. weld.Part1 = character.RightHand
  44. wait(0.1)
  45. weld:Destroy()
  46.  
  47. local velocity = Instance.new("BodyVelocity", fireBall)
  48. velocity.Velocity = CFrame.new(fireBall.Position, mousePos).LookVector * 100
  49.  
  50. --Explosion--
  51. fireBall.Touched:Connect(function(hit)
  52. if hit:IsDescendantOf(character)or hit:FindFirstChild("ParticleEmitter") then return end
  53. explosion.Position = fireBall.Position
  54. fireBall:Destroy()
  55. explosion.Parent = workspace
  56.  
  57. if hit.Parent:FindFirstChild("Humanoid") then
  58. hit.Parent:FindFirstChild("Humanoid"): TakeDamage(30)
  59.  
  60. end
  61. game.ServerScriptService.MagicSkill.Disabled = true
  62. game.StarterPlayer.StarterPlayerScripts.SkillActivation.Disabled = true
  63. wait(5)
  64. game.ServerScriptService.MagicSkill.Disabled = false
  65. game.StarterPlayer.StarterPlayerScripts.SkillActivation.Disabled = false
  66. wait(5)
  67. explosion:Destroy()
  68. end)
  69. end)
Advertisement
Add Comment
Please, Sign In to add comment