I’m attempting to make a movement system. I’ve added in almost every feature so far and everything works well. The only major feature left is crouching, and to do this I want to change the size of one of the parts. Here’s what I have for it (irrelevant stuff cut out).
local Player = game:GetService("Players").LocalPlayer
local Character = Player.CharacterAdded or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("Humanoid")
Player.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
Humanoid = Character:WaitForChild("Humanoid")
GroundCheck = Character:WaitForChild("GroundCheck")
PlayerHitbox = Character:WaitForChild("PlayerHitbox")
GroundCheck.Position = HumanoidRootPart.Position - Vector3.new(0, 4.2, 0)
PlayerHitbox.Position = HumanoidRootPart.Position - Vector3.new(0, 0.9, 0)
end)
local CrouchEnter = TweenInfo.new(
0.2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
local RootPartCrouchEnterGoal = {
Size = Vector3.new(2.5, 1.8, 1)
}
local RootPartCrouchEnter = TweenService:Create(HumanoidRootPart, CrouchEnter, RootPartCrouchEnterGoal)
The last time I had this I fixed it to defining the HumanoidRootPart how I did it here. For those wondering, this is in a LocalScript, using a StarterCharacter with the primary part set to be the HumanoidRootPart. For everything else where I have needed to define the character, humanoid or the rootpart, it’s worked. I have no clue why this doesn’t, as to me this looks right.
Why are you setting this to the Humanoid instance? It should be the root part instead.
I also don’t understand what are you making the character added event to change those variables where you could just use the :WaitForChild() method to get the instance you need.
Both of those is me being very dumb and not checking my code before posting. I was trying different solutions (that character added event is what I used before), and copy pasted some different stuff in which has messed up a bunch of stuff.
Interestingly now that I’ve fixed that, the error has changed to “WaitForChild is not a valid member of RBXScriptSignal”. No clue what this is, I’ve never seen this before.
fixed code, just in case:
local Player = game:GetService("Players").LocalPlayer
local Character = Player.CharacterAdded or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local CrouchEnter = TweenInfo.new(
0.2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
local RootPartCrouchEnterGoal = {
Size = Vector3.new(2.5, 1.8, 1)
}
local RootPartCrouchEnter = TweenService:Create(HumanoidRootPart, CrouchEnter, RootPartCrouchEnterGoal)