For some unknown reason, when I attempt to change the Humanoid’s WalkSpeed, it returns with an error, “Humanoid is not a valid member of Model”. I do not understand why this is happening, because I have tested this code on different games and it works on that. I have read the code word-for-word and I cannot find the issue. I have also used the search tool and didn’t find any solutions.
(by the way, this is a LocalScript in StarterGui)
local StartPos = game.Workspace.Start.CFrame
local EndPos = game.Workspace.End.CFrame
local Camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
while true do
print("Hi") -- this is a statement to check if it works, which it does
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = StartPos
player.Character.Humanoid.WalkSpeed = 0
local TweenService = game:GetService("TweenService")
local CameraTweenInfo = TweenInfo.new(
5,
Enum.EasingStyle.Quint,
Enum.EasingDirection.InOut,
0,
false,
0
)
local CameraTween = TweenService:Create(Camera.CFrame, CameraTweenInfo, EndPos)
CameraTween:Play()
wait(5)
local CameraTween2 = TweenService:Create(Camera.CFrame, CameraTweenInfo, StartPos)
CameraTween2:Play()
wait(5)
end