I was learning how to make an FPS system follow this tutorial:
Well, it works and the guy who makes the tutorial have really comprehensible code but there are some issues that is worth to mention. Anyway, to be specific, he doesn’t replicate it to the server for the other players can see that i’m holding a gun and i noticed this when i switched to server mode. That is why i spent the entire night and this morning to solve this limitation(not exactly an issue), the reason it takes this much time is because i haven’t figured out that the primarypart just fell of the map countless times and i’ve succeeded to solve it. However, there is another problem
As you can see, when i tried to use the remote event to replicate the coordinate follow client’s camera but it’s just so lag and i do not want my player to experience this. Is there any way to prevent this limitation?
Client script:
repeat
wait()
until game:IsLoaded()
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
player.CameraMode = Enum.CameraMode.LockFirstPerson
local weapon = game:GetService("ReplicatedStorage").AK47
local runservice = game:GetService("RunService")
local aiming = false
local aimCFrame = CFrame.new()
local enable = game:GetService("UserInputService")
enable.MouseIconEnabled = false
runservice.RenderStepped:Connect(function(dt)
local turn = workspace.CurrentCamera.CFrame*CFrame.new(0.7,-1,-0.67)*aimCFrame
game:GetService("ReplicatedStorage").pose:FireServer(turn)
if aiming then
aimCFrame = aimCFrame:Lerp(CFrame.new(-0.7,0.3,1.5),0.1)
else
aimCFrame = aimCFrame:Lerp(CFrame.new(),0.1)
end
end)
mouse.Button2Up:Connect(function()
aiming = false
end)
mouse.Button2Down:Connect(function()
aiming = true
end)
Server script:
local weapon = game:GetService("ReplicatedStorage").AK47:Clone()
weapon.Parent = workspace
local handle = weapon.Handle
handle.Anchored = true
game:GetService("ReplicatedStorage").pose.OnServerEvent:Connect(function(player,turn)
weapon:SetPrimaryPartCFrame(turn)
end)
Appreciate everyone’s support :))