Here's the script:

wait()

local players = game:GetService("Players")
local player = players.LocalPlayer
local UserInputService = game:GetService("UserInputService")

local ev = workspace.Events.FloatFruitEvents.FloatingE
local ev2 = workspace.Events.FloatFruitEvents.FloatingoffE
local ev3 = workspace.Events.FloatFruitEvents.FloatingEv

local mouse = player:GetMouse()
local character = player.Character


UserInputService.InputBegan:Connect(function(key,gameProcessed)
	
	if(gameProcessed) then return end
	
    if key.KeyCode == Enum.KeyCode.F then 
	
	ev3.Script.Disabled = false
	
	wait()
	
local camera = workspace.CurrentCamera
camcf = camera.CFrame

	ev:FireServer(camcf)
	
	local currentLookVector = camera.CFrame.LookVector

camera:GetPropertyChangedSignal("CFrame"):Connect(function()
	
	if(camera.CFrame.LookVector ~= currentLookVector)then
		
		currentLookVector = camera.CFrame.LookVector
	
	
    print("look vector changed")

	camcf = camera.CFrame
	ev3:FireServer(camcf)
	end
	
	end)
end

end)


UserInputService.InputEnded:Connect(function(key,gameProcessed) 
	
	if(gameProcessed) then return end
	
    if key.KeyCode == Enum.KeyCode.F then 
	
	
	ev2:FireServer()
	
	ev3.Script.Disabled = true

end

end)

2 comments

0

I assume this connection: camera:GetPropertyChangedSignal("CFrame"):Connect(function() is firing the ev3 remote too often, what do you need the camera's CFrame for?

0

I need it constantly updated in order for the bodyvelocity to always point where the camera is pointing, basically it's a flight script where the direction of the flight is controlled by the camera.