Why this event isnt working?

Maybe because nothing change. Try again with a script that change the CFrame

1 Like

I tried using

workspace.ship.PrimaryPart.CFrame=workspace.ship.PrimaryPart.CFrame+Vector3.new(0,100,0)

but also nothing

I dont know, but you are attempting to add a Vector3 and a CFrame. I vaguely remember that technically being ok, but try this:

workspace.ship.PrimaryPart.CFrame=workspace.ship.PrimaryPart.CFrame+CFrame.new(Vector3.new(0,100,0))

Just, for be sure, try this (I don’t know if it’s working, I am very bad with CFrame) :
workspace.ship.PrimaryPart.CFrame=CFrame.new(Vector3.new(0,100,0))

ok, but anyway, the cframe change (it go 100 up), but the event wont fire

Send a screenshot of what it looks like in the script, with the explorer open, showing where your script is, and screenshot the whole page.

It’s probably that the Changed event and the RBXScriptSignal returned from GetPropertyChangedSignal will not fire if there’s a change in position and cframe

You can use RunService.Stepped:Connect() to check to see if there are changes in its position

1 Like

But, wait a second… ship is not a model? You can’t detect if the CFrame change with a model!

wait, what, i am detecting if ships primaryparts cframe change

Umm,

.Changed is only used on Instances with the VALUE property like stringvalue, intvalue and boolvalue objects. Do not attempt to use this on actual 3d objects.
Also, using logic, this changed event returns a string value in between its parameters so, how is CFrame a string value in the first place…
Here’s a link if you wanna check it out
Instance | Documentation - Roblox Creator Hub [Instance.Changed event]

1 Like

Even. You can’t detect if the PrimaryPart of a model change.

and vector3 is ok???

What do you mean

If you want to detect vector3 (Position) you have to use

Model.PrimaryPart:GetPropertyChangedSignal("Position"):Connect(function()
  local pos = Model.PrimaryPart.Position
  print("Position changed to", pos)
end)

ok, so when i detect position in 1 function and rotation in second function, will i get same effect as i need?

The event is meant to receive RBXScriptSignal when the property highlighted in the parantheses changes, so

Basically, yes

ok, so i found, that when i push it by my character, the event will not fire, but when i change its position by explorer, the event will fire (cframe event)

That really shouldn’t be happening, is the part anchored or something? If the position is updating and it is visible on the server and the client then the event should be firing regardless aslong as the CFrame or position is actually changing.

this is what its doing


(sry for bad quality, but i have slow upload)

Simply put, property changes in CFrame and Position that are caused by physics won’t fire a part’s Changed event most likely because this would grant Lua access to run during the physics loop, which would cause all sorts of problems apparently:

Edit: You would basically have to sync the data model every 240hz to make the Changed event run properly on CFrames or its derivatives, which is apparently very expensive.

I would personally categorize this as an engine bug because you could just wait until Lua is allowed to run and fire Changed there.

Probably the only legit way to detect changes in CFrame/Position is using a loop, like RunService.Heartbeat:

local part = -- part
local positionChanged = -- bindable event
local cachedPosition = part.Position

RunService.Heartbeat:Connect(function()
    local newPosition = part.Position
    if newPosition ~= cachedPosition then
        positionChanged:Fire(newPosition, cachedPosition)
        cachedPosition = newPosition
    end
end)

And you could listen to the positionChanged event like you would expect from a part’s change in position.

You wouldn’t even need to run the loop that frequently, you could just use a wait loop instead.

@Raretendoblox also offered this solution by the way, this is just a longer explanation of what the problem could be

1 Like

What do you mean? All instances support the Changed event. ValueObjects have a specially designed version of changed that fires only when the Value changes and it fires with the new value as a parameter. All other objects listening to Changed pass the name of the changed property as a parameter instead.

2 Likes