So whenever I am currently writing a script that fires a rocket whenever the play presses E. Which fires an event over to the server with the current camera. But for some reason it confuses the camera with the player? I can’t find out why this is the case so if you could please help me!
Local Script:
-- Variables/Services --
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local remoteEvent = game.ReplicatedStorage.Events.rocketFired
-- Events --
UIS.InputBegan:Connect(function(input, GPS)
if GPS then return end
if input.KeyCode == Enum.KeyCode.E then
local camera = workspace.CurrentCamera
remoteEvent:FireServer(plr, camera)
print("fired rocket event")
end
end)
Server Script:
-- Variables/Services --
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local remoteEvent = RS.Events.rocketFired
-- Events --
remoteEvent.OnServerEvent:Connect(function(plr, camera)
print("rocket event recieved")
local rocket = Instance.new("Part", workspace)
rocket.Position = camera.CFrame.LookVector
rocket.Anchored = true
rocket.CanCollide = false
end)