I want to make a code where a player can use a tool that activates when you have it out and left click to shoot out a electric bird in front them. I have a script that shoots out a electric bird when the player presses c while holding the tool.
In starter pack i have a tool call Thunder Bird. In the tool i inserted a string value called Active and a string value called Equip. I also have a local script in the tool.
--- Equip/UnEquip
local Tool = script.Parent
Tool.Equipped:Connect(function()
Tool.Equip.Value = true
end)
Tool.Unequipped:Connect(function()
Tool.Equip.Value = false
end)
--- Skill
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local Debounce = true
Player = game.Players.LocalPlayer
Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://4608419697"
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.C and Debounce == true and Tool.Equip.Value == true and Tool.Active.Value == "None" then
Debounce = false
Tool.Active.Value = "HieShock"
wait(0.1)
Track1 = Player.Character.Humanoid:LoadAnimation(Animation)
Track1:Play()
wait(0.15)
script.Fire:FireServer(plr)
local hum = Player.Character.Humanoid
for i = 1,30 do
wait()
hum.CameraOffset = Vector3.new(
math.random(-1,1),
math.random(-1,1),
math.random(-1,1)
)
end
hum.CameraOffset = Vector3.new(0,0,0)
wait(0.15)
Tool.Active.Value = "None"
wait(2)
Debounce = true
end
end)
in the local script i have a remote event named Fire and a script called Skill in the remote event Fire
script.Parent.OnServerEvent:Connect(function(plr)
local Alive = true
local Projectile = game.ReplicatedStorage.HieDF.HieShock.IceBird:Clone()
Projectile.Parent = workspace
Projectile.CanCollide = false
Projectile.Anchored = false
Projectile.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,4,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
Projectile.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= plr.Name then
hit.Parent.UpperTorso.Velocity = plr.Character.UpperTorso.CFrame.UpVector * 125
local HitEffect = game.ReplicatedStorage.HieDF.HieShock.ShockwaveFX:Clone()
local ShockwaveFX = game.ReplicatedStorage.HieDF.HieShock.ShockwaveFX:Clone()
HitEffect.Parent = workspace
HitEffect.CFrame = hit.Parent.HumanoidRootPart.CFrame
ShockwaveFX.Parent = workspace
ShockwaveFX.CFrame = hit.Parent.HumanoidRootPart.CFrame
HitEffect.CanCollide = false
HitEffect.Anchored = true
hit.Parent.Humanoid:TakeDamage(5 + plr.Data.DevilFruit.Value)
Projectile:Destroy()
for i = 1,25 do
wait(.05)
HitEffect.Size = HitEffect.Size + Vector3.new(0.5,0.5,0.5)
HitEffect.Transparency = HitEffect.Transparency + 0.1
ShockwaveFX.Transparency = HitEffect.Transparency + 0.1
end
HitEffect:Destroy()
end
if hit.Parent:FindFirstChild("Enemy") and hit.Parent.Name ~= plr.Name and hit.Parent.Enemy.Health >= 0 and Alive == true then
hit.Parent.UpperTorso.Velocity = plr.Character.UpperTorso.CFrame.UpVector * 125
local HitEffect = game.ReplicatedStorage.HieDF.HieShock.ShockwaveFX:Clone()
local ShockwaveFX = game.ReplicatedStorage.HieDF.HieShock.ShockwaveFX:Clone()
HitEffect.Parent = workspace
HitEffect.CFrame = hit.Parent.HumanoidRootPart.CFrame
ShockwaveFX.Parent = workspace
ShockwaveFX.CFrame = hit.Parent.HumanoidRootPart.CFrame
HitEffect.CanCollide = false
HitEffect.Anchored = true
hit.Parent.Enemy:TakeDamage(5 + plr.Data.DevilFruit.Value)
Projectile:Destroy()
if hit.Parent.Enemy.Health <= 0 then
Alive = false
--Kill rewards
local Leader = plr:FindFirstChild("Quest")
plr.Data.Beli.Value = plr.Data.Beli.Value + game.ReplicatedStorage.KillRewards:FindFirstChild(hit.Parent.Name).Beli.Value
plr.Data.Exp.Value = plr.Data.Exp.Value + game.ReplicatedStorage.KillRewards:FindFirstChild(hit.Parent.Name).Exp.Value
if Leader.Type.Value == game.ReplicatedStorage.KillRewards:FindFirstChild(hit.Parent.Name).Type.Value then
if Leader ~= nil then
Leader.Amount.Value = Leader.Amount.Value + 1
Alive = true
end
end
end
for i = 1,25 do
wait(.05)
HitEffect.Size = HitEffect.Size + Vector3.new(0.5,0.5,0.5)
HitEffect.Transparency = HitEffect.Transparency + 0.1
ShockwaveFX.Transparency = HitEffect.Transparency + 0.1
end
HitEffect:Destroy()
end
end)
local BV = Instance.new("BodyVelocity",Projectile)
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 110
wait(0.75)
BV:Destroy()
wait(0.25)
Projectile:Destroy()
end)
In replicated storage i have a folder called HieDf and in that folder i have another folder called HieShock that has a mesh part called IceBird that is the bird that gets shooten.

1 comment
I don't think this is your code, if you're asking how to change such a small portion of it