You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I’m trying to build a player screen GUI for my car chassis.
-
What is the issue? I’ve pre-built the GUI, but I just can’t get the speedometer to report the correct speed. It just says 0.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I did, but I couldn’t find any solutions related to speed reporting. I tried referencing the current Target Speed, the current HingeConstraint Angular Velocity, etc… but I just can’t seem to be able to reference the Hinges or Values from the PlayerGUI.
Here’s my VehicleSeat so far:
The motors:
My current script:
local seat = script.Parent
local guiName = "GUI"
local gui = script:WaitForChild("GUI")
local Players = game:GetService("Players")
local lastplr
-- each time the Occupant property of the seat fires...
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant ~= nil then
local char = seat.Occupant.Parent
local player = Players:GetPlayerFromCharacter(char)
local cloned = gui:Clone()
cloned.Parent = player.PlayerGui
lastplr = {player, cloned} -- store player and Gui in array
else
print("player left")
if lastplr then -- verify lastplayer is not nil
lastplr[2]:Destroy() -- since the table's numerically indexed, we know lastplr[2] will be the Gui
lastplr = nil
end
end
end)
What it looks like when I play:
The script that I want to change the text with:
while true do
wait()
script.Parent.Text = script.Parent.Parent.Parent.Parent.Parent.Speed.Value
end
And the error it throws:
If anyone can help me, it would be appreciated.