local script
local player = game.Players.LocalPlayer
local char = player.Character
local cam = workspace.CurrentCamera
local viewmodel = game.ReplicatedStorage.VmStorage:WaitForChild(“Flashlight”):Clone() or game.ReplicatedStorage.VmStorage.Flashlight:Clone() – just incase it’s already loaded
viewmodel.Parent = game.ReplicatedStorage.VmStorage[“ClonedVm’s”]
local run = game:GetService(“RunService”)
local CameraCF = CFrame.new()
local swayCF = CFrame.new()
local SwayX = 3
local SwayY = 5
local equip = game.ReplicatedStorage.BoolStorage.Flashlight
local uis = game:GetService(“UserInputService”)
task.wait()
local audio = script[“Flashlight Click”]
uis.InputBegan:Connect(function(inp)
if inp.KeyCode == Enum.KeyCode.F then
print(“alive”)
flashlight()
end
end)
function flashlight()
local val = game.ReplicatedStorage.BoolStorage.StartupGui.InGui
if val.Value == false then
if equip.Value == false then
changeIfSwitch()
viewmodel.Handle[“Right Arm”].Color = game.Players.LocalPlayer.Character:WaitForChild(“Right Arm”).Color
viewmodel.Parent = cam
game.Players.LocalPlayer.Character:WaitForChild(“Right Arm”).Transparency = 1
audio:Play()
equip.Value = true
run.RenderStepped:Connect(function()
if game.Players.LocalPlayer.Character:WaitForChild(“Humanoid”).Health > 0 then
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(CameraCF)
local x,y,z = rotation:ToOrientation()
swayCF = swayCF:Lerp(CFrame.new(math.sin(-y)*SwayX,math.sin(x)*SwayY,0), .2)
CameraCF = cam.CFrame
local headCF = player.Character:WaitForChild(“Head”).CFrame
game.ReplicatedStorage.EventStorage.SecondaryFlashlightEvents.on:FireServer(swayCF,SwayX,SwayY,cam,CameraCF,headCF,viewmodel)
end
end)
else
equip.Value = false
viewmodel.Parent = game.ReplicatedStorage.VmStorage[“ClonedVm’s”]
game.Players.LocalPlayer.Character:WaitForChild(“Right Arm”).Transparency = 0
audio:Play()
end
end
end
function hideFlashlightIfDead()
if game.Players.LocalPlayer.Character:WaitForChild(“Humanoid”).Health <= 0 then
equip.Value = false
viewmodel.Parent = game.ReplicatedStorage.VmStorage[“ClonedVm’s”]
game.Players.LocalPlayer.Character:WaitForChild(“Right Arm”).Transparency = 0
end
end
function changeIfSwitch()
if game.ReplicatedStorage.BoolStorage.ThirdPerson.Switch.Value == true then
SwayX = 1
else
SwayX = 2.5
end
end
server script
game.ReplicatedStorage.EventStorage.SecondaryFlashlightEvents.on.OnServerEvent:Connect(function(plr:Player,NUL,swayCF,SwayX,SwayY,cam,CameraCF,headCF,viewmodel)
headCF = plr.Character:WaitForChild(“Head”).CFrame
–CameraCF = cam
viewmodel:SetPrimaryPartCFrame(headCF * CFrame.new(CameraCF.Rotation.X,CameraCF.Rotation.Y,CameraCF.Rotation.Z) * CFrame.new(-0.6,-0.4,0.7)*swayCF)
end)
my problem is with the server script if you take the setprimarypartcframe code and put it in the local it works fine but in server it says invalid argument #2 (Vector3 expected, got number) am i doing something wrong