Рет қаралды 226
Thanks for watching!
Follow my Roblox account: www.roblox.com...
Script (put inside the button):
- script Made by coolgo_lite-
-like and subscribe-
local player = game.Players.LocalPlayer
local button = script.Parent -- TextButton
local redBall = nil
local soundEffect = nil
local animation = nil
local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
local cooldownTime = 5 -- Cooldown time in seconds
local canUseAbility = true -- Variable to track if the ability can be used
button.MouseButton1Click:Connect(function()
-- Prevent ability from being used if on cooldown
if not canUseAbility then
return
end
-- Disable the button for cooldown period (visual feedback if needed)
canUseAbility = false
button.Text = "Cooldown..." -- Change button text to indicate cooldown
-- Ensure the player's character and humanoid are present
if not player.Character or not player.Character:FindFirstChild("HumanoidRootPart") or not humanoid then
warn("Character or HumanoidRootPart not found")
return
end
-- Disable player movement (set WalkSpeed to 0)
humanoid.WalkSpeed = 0
-- Create the red ball
redBall = Instance.new("Part")
redBall.Size = Vector3.new(3, 3, 3)
redBall.Shape = Enum.PartType.Ball
redBall.Color = Color3.fromRGB(255, 0, 0)
redBall.Material = Enum.Material.Neon
redBall.Anchored = true
redBall.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 2, -5)
redBall.Parent = workspace
-- Add sound
soundEffect = Instance.new("Sound")
soundEffect.SoundId = "rbxassetid://9125635285" -- Sound ID
soundEffect.Parent = redBall
soundEffect:Play()
-- Add animation
animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://52154760" -- Animation ID
local animTrack = humanoid:LoadAnimation(animation)
animTrack:Play()
-- Wait for 2 seconds before the ball starts moving
task.wait(2)
-- Unanchor the ball and move it
redBall.Anchored = false
local direction = player.Character.HumanoidRootPart.CFrame.LookVector
local speed = 50 -- Ball speed
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(100000, 100000, 100000)
bodyVelocity.Velocity = direction * speed
bodyVelocity.Parent = redBall
-- Stop animation once the ball launches
animTrack:Stop()
-- Re-enable player movement (reset WalkSpeed to 16)
humanoid.WalkSpeed = 16
-- Function to handle collision
local function onTouch(hit)
-- If it touches a BasePart
if hit:IsA("BasePart") then
if hit ~= redBall then -- Avoid destroying the ball itself
hit:Destroy() -- Destroy the part
end
redBall:Destroy() -- Destroy the ball after the effect
redBall = nil
end
-- If it touches a player
if hit.Parent:FindFirstChild("Humanoid") then
local targetHumanoid = hit.Parent:FindFirstChild("Humanoid")
if targetHumanoid and hit.Parent ~= player.Character then
targetHumanoid.Health = 0 -- Kill the player
redBall:Destroy() -- Destroy the ball
redBall = nil
end
end
end
-- Connect the touch event to the function
redBall.Touched:Connect(onTouch)
-- Destroy the ball after 5 seconds if nothing touched it
task.delay(5, function()
if redBall then
redBall:Destroy()
redBall = nil
end
end)
-- Start cooldown
task.wait(cooldownTime)
-- Re-enable the button and ability after cooldown
button.Text = "Use Ability"
canUseAbility = true
end)