Need Help with Running the RunService Service when Triggering a Proximity Prompt

Hey Everyone! so i’m Currently Working on a Horror Game. & i’m trying to make a Proximity Prompt when it’s Triggered it will give the Player a View Model. But it’s not Working. How do i do this?

My Current Script :
HELP

Is the code inside a local script?

1 Like

Yes, the code is inside a Local Script

Alright, do something like this:

ProximityPrompt.Triggered:Connect(function()
	RunService.RenderStepped:Connect(function()
		-- Render code here
	end)
end)
1 Like

i already tried that before but it still didn’t worked.

Is the proximityprompt and the RenderStepped working normally? You can check by printing

1 Like

Yes both of them are working correctly

Then the problem might lies in your view model code

1 Like

I heavily recommend the use of RunService:BindToRenderStep() as it adds more functionality (specifically :UnbindFromRenderStep()) and makes code much more readable

1 Like

I don’t really see why the render step is necessary unless in missing something, but I would move everything inside the render step directly into the prompt triggered event and see if that works.

1 Like

Viewmodels require to be set to the position of the camera every frame, because the camera isnt a physical object you cant just simply weld it to camera

1 Like

Can you tell me more about View Model? I dunno what VMChair and ChairProp are

1 Like

VMChair is the Viewmodel & ChairProp is just a Prop

Oops I must have missed that. Only the camera should be inside the loop since parenting, prompt disabling, and destroying the model don’t need to be in a loop.

1 Like

Id suggest turning the code specifically (setting the cframe to camera) in this screenshot into its own function
image

After that make the proximity prompt do this

ProximityPrompt.Triggered:Connect(function)
     ProximityPrompt.Enabled = false
     -- Bind To RenderStep here
end)
1 Like

You wanna put it in front of the player camera or smth?

1 Like

OOPS WAIT
Turn all the code in the screenshot EXCEPT the for loop
let me edit my message real quick

1 Like

Furthermore I feel like VMChair:PivotTo(Camera.CFrame) is better for Viewmodels

1 Like

OK so i fixed the Problem, all i needed was a Remote Event that Fired a Local Script in StarterPlayerScripts…

Thanks Everyone for the Help!

I see, didn’t know the problem was that deep

1 Like