- What do you want to achieve? Keep it simple and clear!
Checking if the objectvalue’s value exists
2. What is the issue? Include screenshots / videos if possible!
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Here are the forums i already checked
How to check if the ObjectValue's Value exists
And here are the various method I’ve already tried
if NextNode.Value then
if NextNode.Value ~= nil
if NextNode.Value:IsDescendantOf("workspace")
Here are the codes
-----Route & TargetSpeed-----
while wait(0.01) do
--TargetSpeed--
if BrakeApplied == false then
TargetSpeed.Value = math.clamp(TargetSpeed.Value,0,MaxSpeed.Value)
if Increment ~= "." then
if Increment == "+" then
if TargetSpeed.Value ~= MaxSpeed then
TargetSpeed.Value += 1
end
elseif Increment == "-" then
if TargetSpeed.Value ~= 0 then
TargetSpeed.Value -= 1
end
end
end
TargetSpeed.Value = math.clamp(TargetSpeed.Value,0,MaxSpeed.Value)
end
--Route--
if NextNode.Value:IsDescendantOf(game.Workspace.Railway.Nodes) then
TTNDistance = (Primary.WorldPosition.X - NextNode.Value.WorldPosition.X+
Primary.WorldPosition.Y - NextNode.Value.WorldPosition.Y+
Primary.WorldPosition.Z - NextNode.Value.WorldPosition.Z
)
else
TTNDistance = (
Primary.WorldPosition.X - NextSignal.Value.SignalTransmitter[NextSignal.Value.Name].WorldPosition.X+
Primary.WorldPosition.Y - NextSignal.Value.SignalTransmitter[NextSignal.Value.Name].WorldPosition.Y+
Primary.WorldPosition.Z - NextSignal.Value.SignalTransmitter[NextSignal.Value.Name].WorldPosition.Z
)
end
local SignalPasser = DriverCar.Seat.SignalPassed
if TTNDistance < 1 then
warn("Lower")
if not NextNode.Value:IsDescendantOf(game.Workspace.Railway.Nodes) then --Is a signal
local FNextSignal = NextSignal.Value
local Red = FNextSignal.Red.Value
local White = FNextSignal.White.Value
local Following = FNextSignal.Following.Value
--NextSignal.Value = Following
local node = NextSignal.Value.SignalTransmitter[NextSignal.Value.Name].NextSubNode.Value
if node == nil then
NextNode.Value = nil
else
NextNode.Value = node
end
SignalPasser:Invoke(FNextSignal,Red,White)
else--Is a node
local FNextNode = NextNode.Value
if NextNode.Value.NextSubNode:IsDescendantOf(game.Workspace.Railway.Nodes) and NextNode.Value.NextSubNode.Value.Name == "Node" then--Continues
NextNode.Value = NextNode.Value.NextSubNode.Value
else
NextNode.Value = nil
end
end
end
end