Your tweens not working because the position has to be relative to the cars current rotation.
if the car is rotated 26.432 degrees on an axis on account of the fact its a vehicle your tween has to account for that.
i forget exactly how to do it but look up tutorials on cframe.Lookvector that should get you going in the right direction🫡
It should be easier as the gauge doesn’t move tho right? (For generators, stays in one place)
EDIT: I see why you thought it’s for a car. I forgot to add what it is for in the post.
If it was moving, I would rig it with a Motor6D and then simply change the Transform property on relative clients.
If it’s not moving, I would anchor it and rotate it manually.
Here’s the CFrame code I would start with:
local guage = script.Parent
local pointer = guage.Pointer
local empty = pointer.CFrame
local full = pointer.CFrame * CFrame.Angles(0,1.4,0)
-- pointer.CFrame = empty:Lerp(full, percentTank)
you can use Rigid Constraint to make that
click on Model tab
select the dropdown from here
pick Rigid Constraint
now click on the edge of the red neon pointer and the 2nd time on the black cylinder
anchor the black cylinder and unanchor the red pointer
now rotate the black part and the red pointer will rotate with it
Also changing the fuel value doesn’t make it move for some reason.
local guage = script.Parent
local pointer = guage--.Pointer
local empty = pointer.CFrame
local full = pointer.CFrame * CFrame.Angles(0,1.4,0)
CurrentPercentTank = game.ReplicatedStorage.Generators.Fuel.Values.MainGensFuel.Value
pointer.CFrame = empty:Lerp(full, CurrentPercentTank)
local pivotCF = pivotPart.CFrame -- (this is the central knob around which the dial rotates)
local emptyAngle = 45
local totalRotationAngle = 90 -- (the amount it rotates + the empty angle, so this case will have a max rotation of 135 deg)
local offset = gauge.Size.Y / 2 -- (might have to change this to X or Z depending on how your mesh is made)
fuel.Changed:Connect(function(fuelQuantity)
local ratio = fuelQuantity / maxFuel
local newAngle = emptyAngle + (ratio * totalRotationAngle)
local newCF = pivotCF * CFrame.Angles(0, 0, newAngle) -- might have to flip the axes here asw)
newCF *= CFrame.new(0, offset, 0)
dial.CFrame = newCF
end)
Offset is basically the radius of the imaginary circle in which your dial/hand rotates. Imagine a circle around the central black knob, and the radius of this circle extends upto the center of the gauge. Which means the radius is half the Y size of the gauge.
The blue line is the offset here, radius of the circle, red line is your actual dial and the white dot is the centre. Notice how the circle passes through the centre of the dial and not on through its tips.