I have a local script and a script and a remote event for the fireball, I have no problems except I have no clue at all to make it so that the caster of the fireball doesn't get damaged by the fireball.
Script in ServerScriptService:
game:GetService("ReplicatedStorage").RemoteEvent.OnServerEvent:Connect(function(plr) local fireball = game:GetService("Lighting").FireBending.Fire1 local char = plr.Character local fire = fireball:Clone() fire.Parent = workspace fire.CFrame = char.Humanoid.Torso.CFrame * CFrame.new(0,0,-10) local bodyv = Instance.new("BodyVelocity") bodyv.MaxForce = Vector3.new(1e8,1e8,1e8) bodyv.Velocity = char.Humanoid.Torso.CFrame.lookVector * 150 bodyv.Parent = fire local fireanim1 = char.Humanoid:LoadAnimation(script.FireAnim1) local fireanim2 = char.Humanoid:LoadAnimation(script.FireAnim2) local fireanim3 = char.Humanoid:LoadAnimation(script.FireAnim3) local choose = math.random(1,3) if choose == 1 then fireanim1:Play() elseif choose == 2 then fireanim2:Play() elseif choose == 3 then fireanim3:Play() end wait(2) fire:Destroy() end)
And the LocalScript in the player's backpack:
local UserInputService = game:GetService("UserInputService") local plr = game:GetService("Players").LocalPlayer local mouse = plr:GetMouse() local char = plr.Character or plr.CharacterAdded:wait() local fireball = game:GetService("Lighting"):WaitForChild("FireBending").Fire1 local canattack = true local checkdeath = true UserInputService.InputBegan:Connect(function(input, gameProcessedEvent) if input.KeyCode == Enum.KeyCode.Z and canattack == true and not gameProcessedEvent then game:GetService("ReplicatedStorage").RemoteEvent:FireServer() canattack = false wait(3) canattack = true end end)
You can use :IsDescendantOf() to check if a part is a descendant of another. We can have the fireball check if the part it hits is not a descendant of the character who created the fireball, and if so, damage them.
fire.Touched:Connect(function(Hit) if hit.Parent:FindFirstChild("Humanoid") then --check if the hit part is part of a player or NPC if not Hit:IsDescendantOf(character) then --checks if the hit part is NOT a descendant of the character --Code here end end end)