I am currently making a short cutscene sequence. When the Head of a player touches the trigger’s script, the player’s WalkSpeed should be 0. However, the error says that it’s not a valid member of Head, even though I have NEVER addressed it as being part of Head, and only as Head.Parent.
This is my issue:
The error shown is as followed:
Please note that I am using a StarterCharacter, which is preset to WalkSpeed = 0, but is set to 16 shortly after joining the game due to an unrelated cutscene. Strangely, if it’s preset at 16 the cutscene works as normal. bodyPart is also used to reassign the humanoid’s Health, and changes the color of some of the player’s limbs. Those work as usual, but not WalkSpeed.
Also, other times when I test, the error doesn’t appear but still has a bug.
What is going on? Please help.
Let me see what I can do. I DO have another part named “Head”, which is a mesh. This is because the StarterCharacter needs to be textured, but strangely the head mesh doesnt apply Materials, so I have a second mesh on the part that makes the head look textured.
Edit: Doesn’t make WalkSpeed = 0. No error, though.
I checked the value of the Player’s WalkSpeed throughout each step in the gameplay, up to this cutscene. It works as normal, but the WalkSpeed doesn’t change to 0 when this particular cutscene is triggered. I don’t understand why in particular it’s doing this.
Hi, sorry if this might be a dumb reply, but 3 things:
The “infinite yield possible” warning does not halt the script or stop waiting for the child. It is a warning that it might not be able to find what the script is requesting and could halt the script indefinitely until it is added.
Have you tried something like this:
local function Touched(otherPart: BasePart)
local character = otherPart.Parent;
if character then
local head = character:FindFirstChild("Head") :: BasePart?
if head and head:IsA("BasePart") then
local humanoid = character:FindFirstChildOfClass("Humanoid");
if humanoid then
print("head touched yeah. setting walkspeed");
humanoid.WalkSpeed = 0;
print("i setted it");
else
print("no humanoid");
end
else
if head then
print("head is not a basepart");
else
print("head does not exist");
end
end
else
print("character does not exist");
end
end
to debug it? From experience, sometimes scripts can just completely ignore lines or stop runing altogether without a single warning.
3. If it’s a LocalScript it could (keyword COULD) be a replication issue. Least likely though
local char = bodyPart:FindFirstAncestorOfClass("Model")
if char then
local humanoid = char:FindFirstChildOfClass("Humanoid")
if humanoid then
--do code
Your issue is bodyPart.Parent, use bodyPart:FindFirstAncestorOfClass instead.
Tried this. It still doesn’t work. The callback “part.Touched:Connect(bodyPart)” at the bottom of my script doesn’t work with the code you made.
Gives me a blue line under bodyPart in parenthesis.
Also when I applied the rest of the script to yours a certain way, it did not give me any errors. However it still did not fix the issue, I could still walk.
I completely forgot about this post, but my friend was able to figure out the problem. He made the cutscene local and using certain remote events it worked.