#How do i turn this to a tool?

1 messages · Page 1 of 1 (latest)

celest spindle
#

local script in StarterPlayerScripts called Input:
local Uis = game:GetService("UserInputService")
local replicated = game:GetService("ReplicatedStorage")
local skill1Event = replicated:WaitForChild("Skill1Event")

local debounce = false

Uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
if debounce then return end
debounce = true
skill1Event:FireServer()
wait(1)
debounce = false
end
end)
serverscript in ServerScriptService called SkillHandler (theres also a remote event in replicated storage called "Skill1event" and sound called "Skill1Sound"):

#

local replicated = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")

local skill1Event = replicated:WaitForChild("Skill1Event")

skill1Event.OnServerEvent:Connect(function(player)
local char = player.Character
if not char then return end

local humanoid = char:FindFirstChildOfClass("Humanoid")
local hrp = char:FindFirstChild("HumanoidRootPart")
local arm = char:FindFirstChild("Right Arm") or char:FindFirstChild("RightUpperArm")

if not (humanoid and hrp and arm) then return end

humanoid.WalkSpeed = 0

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://132561658547251"
local track = humanoid:LoadAnimation(anim)
track:Play()
replicated.Skill1sound:Play()

local vfx1 = workspace:FindFirstChild("WaveVFX"):Clone()
vfx1.CFrame = arm.CFrame
vfx1.Anchored = false
vfx1.CanCollide = false
vfx1.Parent = char

local weld = Instance.new("Weld")
weld.Part0 = arm
weld.Part1 = vfx1
weld.Parent = vfx1
weld.C0 = CFrame.new(0, -1.5, 0)

debris:AddItem(vfx1, 1)

task.wait(1)

local hitbox = workspace:FindFirstChild("Hitbox"):Clone()
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.CFrame = hrp.CFrame
hitbox.Parent = workspace
debris:AddItem(hitbox, 0.5)

local hitonce = {}
#

hitbox.Touched:Connect(function(hit)
local enemychar = hit:FindFirstAncestorOfClass("Model")
if not enemychar or enemychar == char then return end
if hitonce[enemychar] then return end

    local enemyhumanoid = enemychar:FindFirstChildOfClass("Humanoid")
    local enemyhrp = enemychar:FindFirstChild("HumanoidRootPart")
    if not (enemyhumanoid and enemyhrp) then return end

    hitonce[enemychar] = true

    enemyhumanoid:TakeDamage(40)

    local knockback = (enemyhrp.Position - hrp.Position).Unit
    enemyhrp.Velocity = knockback * 100 + Vector3.new(0, 50, 0)
end)

local vfx2 = workspace:FindFirstChild("WaveHit"):Clone()
vfx2.CFrame = arm.CFrame
vfx2.Anchored = false
vfx2.CanCollide = false
vfx2.Parent = char

local weld2 = Instance.new("Weld")
weld2.Part0 = arm
weld2.Part1 = vfx2
weld2.Parent = vfx2
weld2.C0 = CFrame.new(0, -0.5, 0)

debris:AddItem(vfx2, 0.5)

task.wait(0.5)
humanoid.WalkSpeed = 16

end)

#

i want to make it so you can only use the ability when a tool is equipped

rapid niche