i have a problem with my script, it shows me an error like in the title but im not sure how to fix it.
the error originates from this line here: (ty for ur help!!)
script:
local somedudethatfollowsu:Model = workspace.somedudethatfollowsu
local somedudethatfollowsuHumanoid:Humanoid = somedudethatfollowsu.Humanoid
local pfs = game:GetService("PathfindingService")
local RS = game:GetService("RunService")
local startingPosition = somedudethatfollowsu:FindFirstChild("HumanoidRootPart").Position
local endingPosition = workspace.SpawnLocation.Position
local connection = nil
local AnimationConnection = nil
local Close = nil
local DB = false
local canJumpDB = false
local animationIDTable = {
["BubblyRun"] = 1018548665,
["CartoonyRun"] = 837009922,
["KnightRun"] = 734325948,
["LevitationRun"] = 619543231,
["MageRun"] = 754635032,
["NinjaRun"] = 658830056,
["OldschoolRun"] = 5319900634,
["RobotRun"] = 619522386,
["RthroHeavyRun"] = 3236849826,
["RthroRun"] = 2510238627,
["StylishRun"] = 619512153,
["SuperheroRun"] = 619528716,
["ToyRun"] = 973766674,
["VampireRun"] = 1113740510,
["FriendlyRunAnim"] = 115085003035345,
["WerewolfRun"] = 1113750642,
["ZombieRun"] = 619536621,
RaiseHurleyAnim = 77303114281512,
LowerHurleyAnim = 138634039282164,
AggressiveRunAnim = 97199751061840
}
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local Humanoid:Humanoid = c:WaitForChild("Humanoid")
local hurley:Tool = somedudethatfollowsu.hurley
if not somedudethatfollowsuHumanoid:EquipTool(hurley) then
somedudethatfollowsuHumanoid:EquipTool(hurley)
else return
end
connection = RS.Heartbeat:Connect(function()
local mag = (somedudethatfollowsu.HumanoidRootPart.Position - c.HumanoidRootPart.Position).Magnitude
somedudethatfollowsuHumanoid:MoveTo(c.HumanoidRootPart.Position)
local function getMagnitude()
local Close = false
if mag > 5 then
Close = false
return Close
else
Close = true
return Close
end
end
Close = getMagnitude()
Humanoid.Died:Connect(function()
connection:Disconnect()
end)
end)
end)
somedudethatfollowsuHumanoid.Running:Connect(function(speed)
local randomNumber = math.random(1,2)
local animFolder = somedudethatfollowsu.Animations
local animation:Animation = animFolder.animation
local animationID = nil--"http://www.roblox.com/asset/?id="..animationIDTable["WeirdRun"]
local animTrack:AnimationTrack = nil
if speed > 0 or somedudethatfollowsuHumanoid.MoveDirection.Magnitude > 0 then
if Close == false then
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["LowerHurleyAnim"]
animation.AnimationId = animationID
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animFolder.animation)
animTrack:Play()
print(animation.AnimationId)
animTrack.Ended:Wait()
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["FriendlyRunAnim"]
animTrack:Play()
print(animation.AnimationId)
elseif Close == true then
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["RaiseHurleyAnim"]
animation.AnimationId = animationID
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animFolder.animation)
animTrack:Play()
print(animation.AnimationId)
animTrack.Ended:Wait()
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["AggressiveRunAnim"]
animTrack:Play()
print(animation.AnimationId)
end
if randomNumber == 1 then
if not canJumpDB then
canJumpDB = true
somedudethatfollowsuHumanoid.Jump = true
canJumpDB = false
end
end
else
if animTrack.IsPlaying then
animTrack.Stop()
animationID = nil
animation.AnimationId = nil
end
end
end)
end)
i chucked in some print statements here and this is what i’m getting from the output. it appears to be spamming the play function on my animations. multiple times.
my print statements:
if Close == false then
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["LowerHurleyAnim"]
animation.AnimationId = animationID
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animFolder.animation)
animTrack:Play()
print(animation.AnimationId)
animTrack.Ended:Wait()
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["FriendlyRunAnim"]
animTrack:Play()
print(animation.AnimationId)
elseif Close == true then
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["RaiseHurleyAnim"]
animation.AnimationId = animationID
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animFolder.animation)
animTrack:Play()
print(animation.AnimationId)
animTrack.Ended:Wait()
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["AggressiveRunAnim"]
animTrack:Play()
print(animation.AnimationId)
end
if randomNumber == 1 then
if not canJumpDB then
canJumpDB = true
somedudethatfollowsuHumanoid.Jump = true
canJumpDB = false
end
end
else
print("test")
end
end)
end)
full script:
local somedudethatfollowsu:Model = workspace.somedudethatfollowsu
local somedudethatfollowsuHumanoid:Humanoid = somedudethatfollowsu.Humanoid
local pfs = game:GetService("PathfindingService")
local RS = game:GetService("RunService")
local startingPosition = somedudethatfollowsu:FindFirstChild("HumanoidRootPart").Position
local endingPosition = workspace.SpawnLocation.Position
local connection = nil
local AnimationConnection = nil
local Close = nil
local DB = false
local canJumpDB = false
local animationIDTable = {
["BubblyRun"] = 1018548665,
["CartoonyRun"] = 837009922,
["KnightRun"] = 734325948,
["LevitationRun"] = 619543231,
["MageRun"] = 754635032,
["NinjaRun"] = 658830056,
["OldschoolRun"] = 5319900634,
["RobotRun"] = 619522386,
["RthroHeavyRun"] = 3236849826,
["RthroRun"] = 2510238627,
["StylishRun"] = 619512153,
["SuperheroRun"] = 619528716,
["ToyRun"] = 973766674,
["VampireRun"] = 1113740510,
["FriendlyRunAnim"] = 115085003035345,
["WerewolfRun"] = 1113750642,
["ZombieRun"] = 619536621,
RaiseHurleyAnim = 77303114281512,
LowerHurleyAnim = 138634039282164,
AggressiveRunAnim = 97199751061840
}
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local Humanoid:Humanoid = c:WaitForChild("Humanoid")
local hurley:Tool = somedudethatfollowsu.hurley
if not somedudethatfollowsuHumanoid:EquipTool(hurley) then
somedudethatfollowsuHumanoid:EquipTool(hurley)
else return
end
connection = RS.Heartbeat:Connect(function()
local mag = (somedudethatfollowsu.HumanoidRootPart.Position - c.HumanoidRootPart.Position).Magnitude
somedudethatfollowsuHumanoid:MoveTo(c.HumanoidRootPart.Position)
local function getMagnitude()
local Close = false
if mag > 5 then
Close = false
return Close
else
Close = true
return Close
end
end
Close = getMagnitude()
Humanoid.Died:Connect(function()
connection:Disconnect()
end)
end)
end)
somedudethatfollowsuHumanoid.Running:Connect(function(speed)
local randomNumber = math.random(1,2)
local animFolder = somedudethatfollowsu.Animations
local animation:Animation = animFolder.animation
local animationID = nil--"http://www.roblox.com/asset/?id="..animationIDTable["WeirdRun"]
local animTrack:AnimationTrack = nil
if speed > 0 or somedudethatfollowsuHumanoid.MoveDirection.Magnitude > 0 then
if Close == false then
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["LowerHurleyAnim"]
animation.AnimationId = animationID
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animFolder.animation)
animTrack:Play()
print(animation.AnimationId)
animTrack.Ended:Wait()
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["FriendlyRunAnim"]
animTrack:Play()
print(animation.AnimationId)
elseif Close == true then
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["RaiseHurleyAnim"]
animation.AnimationId = animationID
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animFolder.animation)
animTrack:Play()
print(animation.AnimationId)
animTrack.Ended:Wait()
animationID = "http://www.roblox.com/asset/?id="..animationIDTable["AggressiveRunAnim"]
animTrack:Play()
print(animation.AnimationId)
end
if randomNumber == 1 then
if not canJumpDB then
canJumpDB = true
somedudethatfollowsuHumanoid.Jump = true
canJumpDB = false
end
end
else
print("test")
end
end)
end)