Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local launcher = script.Parent
- local clickDetector = launcher:WaitForChild("ClickDetector")
- clickDetector.MouseClick:Connect(function(player)
- -- Create the projectile
- local projectile = Instance.new("Part")
- projectile.Shape = Enum.PartType.Ball
- projectile.Size = Vector3.new(1, 1, 1)
- projectile.BrickColor = BrickColor.new("Bright red")
- projectile.Material = Enum.Material.Neon
- projectile.Position = launcher.Position + launcher.CFrame.LookVector * 3
- projectile.Anchored = false
- projectile.CanCollide = true
- projectile.Parent = workspace
- -- Add velocity
- local bodyVelocity = Instance.new("BodyVelocity")
- bodyVelocity.Velocity = launcher.CFrame.LookVector * 100
- bodyVelocity.MaxForce = Vector3.new(1e5, 1e5, 1e5)
- bodyVelocity.Parent = projectile
- -- Detect hits
- projectile.Touched:Connect(function(hit)
- if hit:IsDescendantOf(launcher) then return end -- Prevent hitting self
- if hit.Parent:FindFirstChild("Humanoid") then
- hit.Parent.Humanoid:TakeDamage(25)
- end
- projectile:Destroy()
- end)
- -- Auto-destroy after 5 seconds
- game.Debris:AddItem(projectile, 5)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement