Put these two in StarterPack:
For pressing key: (Local Script)
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local RemoteEvent = game.Workspace.Fired
local UIS = game:GetService("UserInputService")
local Debounce = false
UIS.InputBegan:Connect(function(Input, gameProcessed)
if Input.KeyCode == Enum.KeyCode.F and gameProcessed == false then
if Debounce == true then return end
Debounce = true
RemoteEvent:FireServer()
wait(0.5)
Debounce = false
end
end)
Fireball creation (Normal Script)
game.Workspace.Fired.OnServerEvent:Connect(function(Player, Debounce)
local AlreadyTouched = false
local Character = Player.Character or Player.CharacterAdded:wait()
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://846744780"
animation = Character.Humanoid:LoadAnimation(animation)
animation:Play()
wait(0.5)
local Fireball = Instance.new("Part")
local Fire = Instance.new("ParticleEmitter",Fireball)
Fireball.Name = "Fireball"
Fireball.Shape = Enum.PartType.Ball
Fireball.Size = Vector3.new(2,2,2)
Fireball.Material = Enum.Material.Neon
Fireball.BrickColor = BrickColor.new("Deep orange")
Fireball.CanCollide = false
Fire.LightEmission = NumberRange.new(0.35)
Fire.LightInfluence = NumberRange.new(0)
Fire.Texture = "rbxassetid://405886187"
Fire.Lifetime = NumberRange.new(0.5)
Fire.Rate = 20
Fire.Speed = NumberRange.new(3)
Fire.SpreadAngle = Vector2.new(15.15)
Fireball.Parent = Character
Fireball.CFrame = Character.HumanoidRootPart.CFrame*CFrame.new(0,1,-3)
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = Character.HumanoidRootPart.CFrame.lookVector*100
BV.Parent = Fireball
Fireball.Touched:Connect(function(Hit)
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid == nil then return end
if AlreadyTouched == false then
AlreadyTouched = true
local debris = game:GetService("Debris")
if Humanoid then
local creatorTag = Instance.new("ObjectValue")
creatorTag.Value = Player
creatorTag.Name = "creator"
creatorTag.Parent = Humanoid
debris:AddItem(creatorTag, 1)
end;
if Humanoid.Parent == Character then
Humanoid.Health = Humanoid.Health - 0
else
Humanoid.Health = Humanoid.Health - Humanoid.MaxHealth/2
Fireball:Destroy()
end
end
end)
wait(3)
Fireball:Destroy()
end)
And finally make a RemoteEvent in Workspace named "Fired"
2 comments
The problem's that the script loaded before the attachment was there; to fix this issue, simply use
WaitForChild. :)on line 2 add repeat wait() until game.Players.LocalPlayer