Hello fellow devforum users! I have recently encountered a game breaking bug preventing my boss fight from working. If you see anything wrong with this code please let me know what it is. All help is appreciated!
local fireball = game.ReplicatedStorage.AbilityItems.FireBall
local lava = fireball.Parent.Lava
local target = lava.Parent.Circle
local plrs = game:GetService("Players")
local plr = plrs:GetPlayers()[1] or plrs.PlayerAdded:Wait()
local db = false
local function FireBallRain()
if db == false then
db = true
local new = fireball:Clone()
local new2 = target:Clone()
new2.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0, -2, 0)
task.wait(.7)
new.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0, 15, 0)
new.Anchored = false
wait(2)
new2:Destroy()
wait(5)
new:Destroy()
task.wait(1)
db = false
end
end
for i=1, 10 do
FireBallRain()
end
Thanks in advanced.
the output says something along the lines of “Attempt to index nil with HumanoidRootPart”
Hello, seems like plr.Character is returning nil.
try this instead:
local fireball = game.ReplicatedStorage.AbilityItems.FireBall
local lava = fireball.Parent.Lava
local target = lava.Parent.Circle
local plrs = game:GetService(“Players”)
local plr = plrs:GetPlayers()[1] or plrs.PlayerAdded:Wait()
local char = plr.Character or player.CharacterAdded:Wait()
local db = false
local function FireBallRain()
if db == false then
db = true
local new = fireball:Clone()
local new2 = target:Clone()
new2.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0, -2, 0)
task.wait(.7)
new.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0, 15, 0)
new.Anchored = false
wait(2)
new2:Destroy()
wait(5)
new:Destroy()
task.wait(1)
db = false
end
end
i added in a line that waits for the player’s character to load in. If it still doesn’t work, it would be helpful if you could provide more details about what is wrong