Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a custom speed gui using a vehicle seat?

Hello, I am making a racing game with a friend and we are using built in VehicleSeats. I want to make a custom gui to show how fast the player is going, like this: https://imgur.com/h17r8RH

I can't figure out how to make the gui show and hide when you enter and exit the seat. I also can't figure out how to update the speed, since it dosen't look like VehicleSeats have a CurrentSpeed property or something like that. Here is my current code:

local Occupant = script.Parent.Occupant
Occupant.Changed:Connect(function()
    if Occupant then
	    Occupant.PlayerGui.RaceGUI.Enabled = true
	else
	    Occupant.PlayerGui.RaceGUI.Enabled = false
    end
end)

I get this error:

Workspace.fatTire.driverSeat.gui:3: attempt to index local 'Occupant' (a nil value)

Thanks!!

1 answer

while true do

wait()

if game.Workspace.Vehicle.VehicleSeat.Occupant and game.Workspace.Vehicle.VehicleSeat.Occupant.Parent == script.Parent.Parent then

game.Players.LocalPlayer.PlayerGui.RaceGui.Enabled = true

game.Players.LocalPlayer.PlayerGui.RaceGui.TextLabel.Text = math.floor((game.Workspace.Vehicle.VehicleSeat.Velocity.magnitude * 1) + 0) / 1 --Change "Textlabel" to whatever your textlabel is called.

print("This")

else

game.Players.LocalPlayer.PlayerGui.RaceGui.Enabled = false

end

end

Put this script in StarterCharacterScripts, under StarterPlayer.

1 comment

0

If this doesn't work, tell me.

This discussion is preserved as it was. New answers, comments, and votes are closed.