On youtube a video that is called Christmas Special! | How to make an snowman boss. at the script that he used in video i always get an error. Can somone fix the problem?
local Humanoid = script.Parent:WaitForChild("Humanoid")
local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local WalkRange = 20
local AcidBallSpeed = 50
local Closest = nil
spawn(function()
while true do
wait()
if Closest ~= nil then
HumanoidRootPart.BodyGyro.CFrame = CFrame.new(HumanoidRootPart.Position,Vector3.new(Closest.Character.HumanoidRootPart.Position.X,HumanoidRootPart.Position.Y,Closest.Character.HumanoidRootPart.Position.Z))
end
end
end)
while true do
wait(2)
local RandomValue = math.random(0,10)
local List = {}
for i,v in pairs(game.Players:GetChildren()) do
if v and v.Character then
local Distance = (HumanoidRootPart.Position - v.Character.HumanoidRootPart.Position).Magnitude
table.insert(List,{v,Distance})
end
end
table.sort(List,function(A,B)
return A[2] <= B[2]
end)
if #List >= 1 then
Closest = List[1][1]
if RandomValue > 0 and RandomValue < 6 then
local RandomWalkPosition = Vector3.new(math.random(-WalkRange,WalkRange),0,math.random(-WalkRange,WalkRange))
Humanoid:MoveTo(HumanoidRootPart.Position+RandomWalkPosition)
else
local AcidBall = Instance.new("Part")
AcidBall.Anchored = false
AcidBall.Shape = "Ball"
AcidBall.Size = Vector3.new(4,4,4)
AcidBall.TopSurface = Enum.SurfaceType.Smooth
AcidBall.BottomSurface = Enum.SurfaceType.Smooth
AcidBall.Material = Enum.Material.Neon
AcidBall.BrickColor = BrickColor.new("Lime green")
AcidBall.CFrame = HumanoidRootPart.CFrame*CFrame.new(0,0,-10)
AcidBall.Parent = workspace
AcidBall.CanCollide = false
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(100000,100000,100000)
local Origin = HumanoidRootPart.Position
BV.Velocity = (List[1][1].Character.HumanoidRootPart.Position - Origin).unit * AcidBallSpeed
BV.Parent = AcidBall
spawn(function()
wait(1)
AcidBall.Touched:Connect(function(Hit)
if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then
Hit.Parent.Humanoid:TakeDamage(20)
end
AcidBall:Destroy()
end)
end)
wait(2)
end
end
end

4 comments
v.Character or v.CharacterAdded:Wait()
what
What is the error exactly and at what line as I can't test rn?
v.Character or v.CharacterAdded:Wait() works like this: if the character already exists, the variable you assign the statement to is assigned to the character; however, if the character doesn't exist yet, it waits for CharacterAdded to fire, and then assigns the variable to the character argument that CharacterAdded passes