How should i do this (proximity prompt)

basically, i have a proximity prompt inside of model in workspace, but the problem is, the code is in a local script and it has to be as it has code for tweening the camera. im aware that local scripts cant be in workspace, so what should i do? here is the code:
LOCAL SCRIPT:

local Prox = script.Parent
local Player = game:GetService("Players")
local FuseEvent = game:GetService("ReplicatedStorage"):WaitForChild("FuseFixed")
local Camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local Char = Player.LocalPlayer.Character or Player.LocalPlayer.CharacterAdded:Wait()
local FixAnim = Char.Humanoid.Animator:LoadAnimation(script:WaitForChild("Animation"))
local CameraFixing = TweenInfo.new(.4, -- Time
	Enum.EasingStyle.Quad, -- EasingStyle
	Enum.EasingDirection.InOut, -- EasingDirection
	0, -- RepeatCount (when less than zero the tween will loop indefinitely)
	false, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime) -- Let's use all defaults here
)

local CameraFix1 = TweenService:Create(Camera, CameraFixing, {
	CFrame = Prox.Parent.Parent.ProxCam1.CFrame
})


local CameraFixing2 = TweenInfo.new(4, -- Time
	Enum.EasingStyle.Quad, -- EasingStyle
	Enum.EasingDirection.InOut, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	true, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime) -- Let's use all defaults here
)

local CameraFix2 = TweenService:Create(Camera, CameraFixing, {
	CFrame = Prox.Parent.Parent.ProxCam2.CFrame
})


local function ResetCam()
	task.wait()
	Camera.CameraType = Enum.CameraType.Custom
	task.wait()
	Camera.CameraSubject = Char.Humanoid
end




Prox.PromptButtonHoldBegan:Connect(function()
	task.wait()
	Camera.CameraType = Enum.CameraType.Scriptable
	task.wait()
			FixAnim:Play()
			CameraFix1:Play()
		CameraFix1.Completed:Connect(function()
			CameraFix2:Play()
			end)
		end)

Prox.PromptButtonHoldEnded:Connect(function()
	ResetCam()
			FixAnim:Stop()
			CameraFix1:Cancel()
			CameraFix2:Cancel()
		end)

Prox.Triggered:Connect(function()
	ResetCam()
			print("Fuse Fixed")
			CameraFix1:Cancel()
			CameraFix2:Cancel()
			FixAnim:Stop()
			FuseEvent:FireServer()
		end)

SERVER SCRIPT (for remote event):

local FuseEvent = game:GetService("ReplicatedStorage"):WaitForChild("FuseFixed")

FuseEvent.OnServerEvent:Connect(function()
	local TweenService = game:GetService("TweenService")
	local FuseGUI = game:GetService("StarterGui"):WaitForChild("FuseFixed")
	local Text = FuseGUI.TextLabel
	
	FuseGUI.Enabled = true
	FuseGUI.TextLabel.Visible = true
	FuseGUI.TextLabel.Frame.Visible = true
	
	local FuseTween = TweenInfo.new(4, -- Time
		Enum.EasingStyle.Bounce, -- EasingStyle
		Enum.EasingDirection.In, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime) -- Let's use all defaults here
	)

	local FuseText = TweenService:Create(
		Text, FuseTween, {TextTransparency = 0})
	
	local FuseTween = TweenInfo.new(4, -- Time
		Enum.EasingStyle.Bounce, -- EasingStyle
		Enum.EasingDirection.In, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime) -- Let's use all defaults here
	)

	local FuseText2 = TweenService:Create(
		Text, FuseTween, {TextTransparency = 1})
	
	
	print("FIXED")
	FuseText:Play()
	task.wait(3)
	FuseText2:Play()
end)
1 Like

You can try using :FireClient()
Api reference RemoteEvent/FireClient
have a local script that picks up the event with OnClientEvent and tweens the camera.

1 Like

so would i have to fire a remote for every time the hold begins/ends?
so i can show the anim?
would i need 3 different remotes?
and how should i get the parts for the camera that are in workspace in the local script

put the script in player gui and use the absolute path of the proximity prompt instead of using script.Parent

  1. Yes
  2. Yes
  3. You can use 1 remote that does something like: FireClient(Player, true) – true being to play the animation for the cameras and false being to stop it or setting the camera back to normal.
  4. You can manually put each camera part inside a table or you can put the cameraparts inside a folder each named their own number in order and do a loop like:
for i, v in ipairs(CameraParts:GetChildren()) do
       if v.Name == i then
              TweenCameraToPart(v) -- make a function that tweens camera to a part
       end
end)

i ended up doing this a different way, using 2 remotes, but ill give you the solution anyway