So I made a script where you press “Q” to turn your flames on, and then whilst it is on you can fire a fireball however while it does fire the fireball, it de-activates the flames then fires it.
Is anyone able to help…?
VIDEO:
(In the video when I cast the fireball it disables the fire then launches the fireball.)
LOCAL SCRIPT:
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local activated = false
local casting = false
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.Q then
activated = not activated
ReplicatedStorage.Remotes.FlameOn:FireServer(activated)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 and activated then
casting = not casting
ReplicatedStorage.Remotes.FlameOn:FireServer(activated, casting, mouse.Hit)
end
end)
SERVER SCRIPT:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local debounce = false
local casted = false
local hasActivated = false
ReplicatedStorage.Remotes.FlameOn.OnServerEvent:Connect(function(player, activated, casting, mouse)
if debounce then return end
local character = player.Character
local fire = script.Fire:Clone()
local fire2 = script.Fire:Clone()
fire2.Name = "Fire 2"
if activated and not hasActivated then
hasActivated = true
local weld = Instance.new("WeldConstraint")
weld.Name = "Fire Weld"
weld.Part0 = fire
weld.Part1 = character["Right Arm"]
fire.CFrame = character["Right Arm"].CFrame * CFrame.new(0, -0.65, 0)
local weld2 = Instance.new("WeldConstraint")
weld2.Name = "Fire Weld 2"
weld2.Part0 = fire2
weld2.Part1 = character["Left Arm"]
fire2.CFrame = character["Left Arm"].CFrame * CFrame.new(0, -0.65, 0)
fire.Parent = character
fire2.Parent = character
weld.Parent = fire
weld2.Parent = fire2
else
character:FindFirstChild("Fire"):Destroy()
character:FindFirstChild("Fire 2"):Destroy()
hasActivated = false
end
-- for casting fireball
if casting and not casted then
casted = true
local fireball = script.Fireball:Clone()
local weld = Instance.new("WeldConstraint")
weld.Part0 = fireball
weld.Part1 = character["Right Arm"]
fireball.CFrame = character["Right Arm"].CFrame
weld.Parent = fireball
local fireCast = character.Humanoid:LoadAnimation(script.FireCast)
fireCast:Play()
fireCast:GetMarkerReachedSignal("Cast"):Connect(function()
fireCast:AdjustSpeed(0)
fireball.Parent = workspace
wait(0.2)
weld:Destroy()
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Velocity = CFrame.new(fireball.Position, mouse.Position).lookVector * 100
bodyVelocity.Parent = fireball
fireCast:AdjustSpeed(1)
end)
fireball.Touched:Connect(function(hit)
if hit:IsDescendantOf(character) or hit:FindFirstChild("Fire") then return end
fireball:Destroy()
if hit.Parent:FindFirstChild("Humanoid") then
local target = hit.Parent
target.Humanoid:TakeDamage(10)
fireball:Destroy()
end
end)
wait(1.2)
casted = false
end
end)