Wheels can't be called; Datamodel Error

Hi, I’m trying to call the wheels in my local script, but I’m always getting this error: Wheels is not a valid member of DataModel “BloxKart Testing - Elements @ 15 Nov 2020 12:47”

This is my script:

local motorFR = kart.Wheels.AxelFR.Motor
local motorFL = kart.Wheels.AxelFL.Motor
local motorRR = kart.Wheels.AxelRR.Motor
local motorRL = kart.Wheels.AxelRL.Motor

local servoFR = kart.Wheels.ServoFR.Servo
local servoFL = kart.Wheels.ServoFL.Servo

“Wheels” is a model and the axels and servos are parented to “Wheels”

Use :WaitForChild(“”);

local motorFR = kart:WaitForChild("Wheels"):WaitForChild("AxelFR").Motor
local motorFL = kart.Wheels:WaitForChild("AxelFL").Motor
local motorRR = kart.Wheels:WaitForChild("AxelRR").Motor
local motorRL = kart.Wheels:WaitForChild("AxelRL").Motor

local servoFR = kart.Wheels:WaitForChild("ServoFR").Servo
local servoFL = kart.Wheels:WaitForChild("ServoFL").Servo

If this doesn’t work, can you please send a screenshot of explorer with the descendants (which you’re calling) of the kart.

The errors went away, however, the values of the Torque and AngularVelocity aren’t changing in the script.

Here is my other part of the script:


	throttle = 1
	motorFR.AngularVelocity = 500 * throttle
	motorFL.AngularVelocity = -500 * throttle
	motorRR.AngularVelocity = 500 * throttle
	motorRL.AngularVelocity = -500 * throttle

EDIT: A warning appeared: Infinite yield possible on ‘BloxKart Testing - Elements @ 15 Nov 2020 13:06:WaitForChild(“Wheels”)’

Double check all your references and make sure Wheels is a valid descendent of whatever you’re running WaitForChild() on.

It should be…? Here’s my explorer:

image

image

Can you reply with your code and comment the line that is using WaitForChild(“Wheels”)?

Here’s my full script:

local gui = script.Parent
local seat = gui.Seat

local kart = script.Parent.Parent.Parent.Parent.Parent

local runService = game:GetService("RunService")


local motorFR = kart:WaitForChild("Wheels"):WaitForChild("AxelFR").Motor
local motorFL = kart:WaitForChild("Wheels").AxelFL.Motor
local motorRR = kart:WaitForChild("Wheels").AxelRR.Motor
local motorRL = kart:WaitForChild("Wheels").AxelRL.Motor

local servoFR = kart:WaitForChild("Wheels").ServoFR.Servo
local servoFL = kart:WaitForChild("Wheels").ServoFL.Servo

print(motorFR.AngularVelocity)

local throttle = 1
local steer = 0


function Init()
	motorFR.MotorMaxTorque = 10000
	motorFL.MotorMaxTorque = 10000
	motorRR.MotorMaxTorque = 10000
	motorRL.MotorMaxTorque = 10000

	while runService.RenderStepped:Wait() do
		Update()

	end
end

function Update()
	
	throttle = 1
	motorFR.AngularVelocity = 500 * throttle
	motorFL.AngularVelocity = -500 * throttle
	motorRR.AngularVelocity = 500 * throttle
	motorRL.AngularVelocity = -500 * throttle
end

Init()

And this script is the ChassisScript, correct?

No, this is the controls script. It’s a local script and you can see where it’s located in the images above.

Is the ControlScript being moved to a descendent of the Player whenever the occupant of the seat changes? (PlayerGui, PlayerScripts, etc)

It’s moved to the playergui in the chassis script here:

function PlayerConnect(weld) 
	if weld.Name == "SeatWeld" then
		local char = weld.Part1.Parent
		local plr = game.Players:FindFirstChild(char.Name)
		
		if plr ~= nil then
			local clone = script.SeatGui:Clone()
			clone.Parent = plr.PlayerGui
		end
	end
end

Refer to this response to a similar situation and see if that helps:

Edit: If you still need help after reading this, feel free to shoot me a private message.

For future reference for people who may run into a similar error.

I don’t know how I overlooked this in the original post, but the reference to kart was yielding because the client wasn’t given enough time to locate the resource (the kart).

1 Like