Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does Changed in an VehicleSeat for on Property not work on Position just on Throttle,Steer ??

Asked by 6 years ago

I think I need the Change of an property which changes often or permanent to update the gear,cause with Throttle it dont works cause it only updates when Throttle changes to -1,0,1 and while you are driving you dont release everytime W or press S.

local dseat=script.Parent
local car=seat.Parent.Parent
local leftdrive = car.Chassis.Backbodie.Lbackmotor
local rightdrive = car.Chassis.Backbodie.Rbackmotor



local function drive (property)
 if property == "Throttle" then 
  leftdrive.AngularVelocity = 50 * seat.Throttle 
  rightdrive.AngularVelocity = -50 * seat.Throttle 
end
if property == "Position" then 
 print("GearChangeTest")
end

1 answer

Log in to vote
0
Answered by 6 years ago

For some odd reason, some properties changing do not trigger the Changed event. An easy way to fix this is to use Heartbeat and check if the values changed. For example,

local pos = part.Position
local size = part.Size

game:GetService('RunService').Heartbeat:Connect(function()
    if pos ~= part.Position then
        print('Position changed')
        pos = part.Position
    end
    if size ~= part.Size then
        print('Size changed')
        size = part.Size
    end
end)

Since I don't really know what you connected the Change event to, I could not provide a script you can use, but you can modify the script I provided

Hope this helps!

0
Thx for this answer,I think this will help me, goldi111 -5 — 6y
Ad

Answer this question