SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --//Local Script
  2. local UIS = game:GetService("UserInputService")
  3. local debounce = false
  4.  
  5. --PC
  6. UIS.InputBegan:Connect(function(key, processed)
  7.     if processed or debounce then return end
  8.     debounce = true
  9.    
  10.     if key.UserInputType == Enum.UserInputType.Keyboard then
  11.         if key.KeyCode == Enum.KeyCode.Z then
  12.             game.ReplicatedStorage.Events.FireBall:FireServer(mouse.Hit.Position)
  13.         end
  14.     end
  15.     wait(1)
  16.     debounce = false
  17. end)
  18.  
  19. --Mobile
  20. if UIS.TouchEnabled then
  21.     UIS.TouchTap:Connect(function(position, processed)
  22.         if processed or debounce then return end
  23.         debounce = true
  24.        
  25.         game.ReplicatedStorage.Events.FireBall:FireServer(mouse.Hit.Position)
  26.         wait(1)
  27.         debounce = false
  28.     end)
  29. end
  30.  
  31.  
  32. --//Server Script
  33. game.ReplicatedStorage.Events.FireBall.OnServerEvent:Connect(function(player, mousePos)
  34.     local effects = game.ReplicatedStorage.FireBallEffects
  35.     local fireBall = effects.FireBall:Clone()
  36.     local explosion = effects.Explosion:Clone()
  37.     local character = player.Character
  38.  
  39.     --Fireball
  40.     fireBall.Position = character.HumanoidRootPart.Position
  41.     fireBall.Parent = workspace
  42.     local velocity = Instance.new("BodyVelocity", fireBall)
  43.     velocity.Velocity = CFrame.new(fireBall.Position, mousePos).LookVector * 100
  44.    
  45.     --Explosion
  46.     fireBall.Touched:Connect(function(hit)
  47.         if hit:IsDescendantOf(character) or hit:FindFirstChild("ParticleEmitter") then return end
  48.         explosion.Position = fireBall.Position
  49.         fireBall:Destroy()
  50.         explosion.Parent = workspace
  51.        
  52.         if hit.Parent:FindFirstChild("Humanoid") then
  53.             hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
  54.         end
  55.        
  56.         wait(1)
  57.         explosion:Destroy()
  58.     end)
  59. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top