thegamer_guy
Coder
I need help with a gas gauge for a car in Roblox.
Setup: DriveSeat (VehicleSeat) and GasValue (NumberValue) are in the same car model. A GasGUI with a TextLabel displays the gas percentage. Problem:
The script only shows "Gas: --%" even when I enter the car.
Script Snippet:
local gasLabel = script.Parent gasLabel.Text = "Gas: --%" local function onDriveSeatChanged(driveSeat) if driveSeat.Occupant and driveSeat.Occupant.Parent == player.Character then local car = driveSeat.Parent local gasValue = car:FindFirstChild("GasValue") if gasValue then gasLabel.Text = "Gas: " .. math.floor(gasValue.Value) .. "%" gasValue:GetPropertyChangedSignal("Value"):Connect(function() gasLabel.Text = "Gas: " .. math.floor(gasValue.Value) .. "%" end) else gasLabel.Text = "Gas: N/A" end else gasLabel.Text = "Gas: --%" end end``` What am I doing wrong? I used a
I want it to show how much gas is in the car, but it just says ""Gas: --%""
Please Help me.
Setup: DriveSeat (VehicleSeat) and GasValue (NumberValue) are in the same car model. A GasGUI with a TextLabel displays the gas percentage. Problem:
The script only shows "Gas: --%" even when I enter the car.
Script Snippet:
local gasLabel = script.Parent gasLabel.Text = "Gas: --%" local function onDriveSeatChanged(driveSeat) if driveSeat.Occupant and driveSeat.Occupant.Parent == player.Character then local car = driveSeat.Parent local gasValue = car:FindFirstChild("GasValue") if gasValue then gasLabel.Text = "Gas: " .. math.floor(gasValue.Value) .. "%" gasValue:GetPropertyChangedSignal("Value"):Connect(function() gasLabel.Text = "Gas: " .. math.floor(gasValue.Value) .. "%" end) else gasLabel.Text = "Gas: N/A" end else gasLabel.Text = "Gas: --%" end end``` What am I doing wrong? I used a
LocalScript
in the TextLabel
. I want it to show how much gas is in the car, but it just says ""Gas: --%""
Please Help me.