Setting the CFrame of a model in LocalScript prevents model from being visible

So, I encountered an insanely weird and frustrating issue.

I want to make a pistol that basically follows the camera. For now I just want for it to appear in front of it.
Well, for whatever reason, it is completely invisible during playtesting.


I have zero clue why or how, but this issue does not allow me to develop my place any futher. Meshes are infact not corrupted, because this happens even with a single part.

I have to set the CFrame of the model via LocalScript, otherwise the rotation will be affected by ping, which I do not want.
I made literally the same with SpotLight when making a flashlight in the same place, and it does work.

Edit: Model is parented to StarterCharacterScripts.

Just a wild guess, but I’m thinking your part/model needs to be a descendant of the workspace if you want it to be seen.

1 Like

I tried to parent it to workspace. Didn’t work.

Your script must not be in the workspace (unless its in the Character), but the part/model must be.

1 Like

My LocalScript that sets the CFrame is not parented to workspace, but rather to the model. Which is inside the character.

I have a question: Try printing the CFrame. Sometimes absurd CFrames mess up the rendering of objects
Edit: absurd cframes as in something like CFrame.new(0,2,10,-1,-2,-2,0,1,-1,-1,0,-1)

Sounds like it should work then, I’m out of ideas.

Got this.

-0.212312177, 6.06945467, -15.3753147, 1, -2.44084026e-06, -2.98023117e-08, 2.17882939e-06, 0.898027122, -0.439940304, 1.10058727e-06, 0.439940304, 0.898027122

Not sure if this is normal or not. I dont understand what those numbers mean.
I know that first four are X, Y, Z, W but that’s about it.

Yeah they look absolute normal. It might just be a studio bug. for context, CFrame.new has 9 optional overflows, CFrame.new([2,2,2]Position,[1,0,0,0,1,0,0,0,1]RotationMatrix)

I need to find a workaround though. I can’t handle CFrame from a global script.

I found the fix.

Instead of using LocalScript, I will use Script with Client RunContext.
Changed the parent of the model to Workspace instead of StarterCharacterScripts.

I do think that this is a bug in studio, because parenting model to character basically makes it invisible.
Thanks for your help.

edit: Can someone post this in bug report category? I am not a regular, so I can’t.

1 Like

Nah it isnt a bug. BoundingBoxes are rendered on parts inheriting Instance inside of any Non-Hidden service

1 Like

Good to know…
I could’ve fixed it by parenting the script to ReplicatedFirst, and model to Workspace then ref the model in the script. Though I think that using Script with Client RunContext is better.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.