Hello everyone, i have my game and this error, im not sure what it means or how to fix it, like the game/script works normally, but its annoying seeing this error message in the output. Any ideas on a solution?
this is the script (the second part of the script is to play a sound based on proximity of the killer to the survivor):
--** Does stuff for when the player is in danger
--// Services
local Players: Players = game:GetService("Players")
local Run: RunService = game:GetService("RunService")
--// Instances
local Player = Players.LocalPlayer
--// Fields
local Update = os.time()
local UpdateRate = 1 -- Chase update rate
local ChaseRange = 60
local ChaseFade = false
--// Connections
Player.CharacterAdded:Connect(function(Character: Model)
local Humanoid: Humanoid = Character:WaitForChild("Humanoid")
script.LowHealth:Stop()
script.Chase:Stop()
Humanoid.HealthChanged:Connect(function(health: number)
if Player.IsCurse.Value == false then
if health <= Humanoid.MaxHealth / 2 then
Character.Animate.run.RunAnim.AnimationId = "rbxassetid://8750913972" -- Limping animation ID
script.LowHealth:Play()
else
Character.Animate.run.RunAnim.AnimationId = "rbxassetid://913376220"
script.LowHealth:Stop()
end
end
end)
Humanoid.Died:Connect(function()
script.LowHealth:Stop()
script.Chase:Stop()
end)
end)
Run:BindToRenderStep("Chase", Enum.RenderPriority.Last.Value, function()
local Players: {Instance} = Players:GetPlayers()
for i = 1, #Players do
if Players[i]:FindFirstChild("IsCurse") and Players[i].IsCurse.Value and Players[i] ~= Player then
local Curse = Players[i]
if Curse.Character.PrimaryPart then
if (Curse.Character.PrimaryPart.Position-Player.Character.PrimaryPart.Position).Magnitude <= ChaseRange and not script.Chase.Playing then
ChaseFade = false
script.Chase.Volume = 3
script.Chase:Play()
elseif (Curse.Character.PrimaryPart.Position-Player.Character.PrimaryPart.Position).Magnitude > ChaseRange and script.Chase.Playing then
ChaseFade = true
task.spawn(function()
for i = 1, 0, -0.1 do task.wait(1 / 10)
if not ChaseFade then break end
script.Chase.Volume = i
end
script.Chase:Stop()
ChaseFade = false
end)
end
end
end
end
end)
Any help would be appreciated, me and my friend are stuck on this.
The RunService:BindToRenderStep() is run when your HumanoidRootPart hasn’t loaded yet. Try this:
--** Does stuff for when the player is in danger
--// Services
local Players: Players = game:GetService("Players")
local Run: RunService = game:GetService("RunService")
--// Instances
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Hum_RT = Character:WaitForChild("HumanoidRootPart")
--// Fields
local Update = os.time()
local UpdateRate = 1 -- Chase update rate
local ChaseRange = 60
local ChaseFade = false
--// Connections
Player.CharacterAdded:Connect(function(Character: Model)
local Humanoid: Humanoid = Character:WaitForChild("Humanoid")
script.LowHealth:Stop()
script.Chase:Stop()
Humanoid.HealthChanged:Connect(function(health: number)
if Player.IsCurse.Value == false then
if health <= Humanoid.MaxHealth / 2 then
Character.Animate.run.RunAnim.AnimationId = "rbxassetid://8750913972" -- Limping animation ID
script.LowHealth:Play()
else
Character.Animate.run.RunAnim.AnimationId = "rbxassetid://913376220"
script.LowHealth:Stop()
end
end
end)
Humanoid.Died:Connect(function()
script.LowHealth:Stop()
script.Chase:Stop()
end)
end)
Run:BindToRenderStep("Chase", Enum.RenderPriority.Last.Value, function()
local Players: {Instance} = Players:GetPlayers()
for i = 1, #Players do
if Players[i]:FindFirstChild("IsCurse") and Players[i].IsCurse.Value and Players[i] ~= Player then
local Curse = Players[i]
local char = Curse.Character or Curse.CharacterAdded:Wait()
local hum_rt = char:WaitForChild("HumanoidRootPart")
if hum_rt then
if (hum_rt .Position-Hum_RT .Position).Magnitude <= ChaseRange and not script.Chase.Playing then
ChaseFade = false
script.Chase.Volume = 3
script.Chase:Play()
elseif (hum_rt .Position-Hum_RT .Position).Magnitude > ChaseRange and script.Chase.Playing then
ChaseFade = true
task.spawn(function()
for i = 1, 0, -0.1 do task.wait(1 / 10)
if not ChaseFade then break end
script.Chase.Volume = i
end
script.Chase:Stop()
ChaseFade = false
end)
end
end
end
end
end)