In short terms there is this issue of the bullets which are being shot from a gun which i had scripted and the bullets appear laggy and behind the player and not exact where the player had shot it.
Sorry my about my code being unclean.
Server CODE:
--main local remote = game.ReplicatedStorage.RemoteEwents.Remote1 disabled = false remote.OnServerEvent:connect(function(player,barrelpos,mousepos,distance,name) local plr = game.Players.LocalPlayer local chr = player.Character local tool = chr:FindFirstChild(name) local dmg = tool.Handle.Damage.Value local ammo = tool.Handle.Ammo local reloadtime = tool.Handle.Reloadtime local reloading = false local maxammo = tool.Handle.MaxAmmo local function reload() reloading = false ammo.Value = maxammo.Value disabled = true tool.Handle.Reload:Play() wait(tool.Handle.Reloadtime.Value) disabled = false end --creator if ammo.Value <= 0 then reloading = true if reloading == true then reload() wait(reloadtime.Value) end end local function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.R then reloading = true if reloading == true then reload() wait(reloadtime.Value) end end end game:GetService("UserInputService").InputBegan:connect(onKeyPress) if ammo.Value >=1 and reloading == false and disabled == false then local ray = Ray.new(barrelpos, (mousepos - barrelpos).unit * 3000) local part,position = game.Workspace:FindPartOnRay(ray, player.Character,false,true) local bullet = Instance.new("Part") ammo.Value = ammo.Value - 1 tool.Handle.Fire:Play() bullet.Anchored = true bullet.CanCollide = false bullet.BrickColor = player.TeamColor bullet.FormFactor = "Custom" local dist = (barrelpos - mousepos).magnitude bullet.Size = Vector3.new(0.3,0.3,dist) bullet.Parent = workspace bullet.TopSurface = "Smooth" bullet.BottomSurface = "Smooth" bullet.Transparency = 0.5 game.Debris:AddItem(bullet,0.1) for i = 0, dist,6 do bullet.CFrame = CFrame.new(tool.Barrel.CFrame.p,position) * CFrame.new(0,0, -dist/2) end if part then local humanoid = part.Parent:FindFirstChild("Humanoid") if humanoid then local plrname = part.Parent.Name local players = game.Players:FindFirstChild(plrname) print(plrname) local plrname1 = player.Name if player.TeamColor ~= players.TeamColor and tool.Handle.Teamkill.Value == false then humanoid:TakeDamage(dmg) tool.Handle.Click:Play() else print("isinteam") if tool.Handle.Teamkill.Value == true then humanoid:TakeDamage(dmg) end end local killed = false local creator = Instance.new("StringValue") if humanoid.Health <= 0 then end end end end end)
Client code:
local Player = game.Players.LocalPlayer wait(0.5) local gun = script.Parent local remote = game.ReplicatedStorage.RemoteEwents.Remote1 local pgui = Player.PlayerGui.ammo.Frame local maxammo = script.Parent.Handle.MaxAmmo local ammo = script.Parent.Handle.Ammo gun.Equipped:Connect(function(mouse) pgui.Visible = true gun.Unequipped:connect(function() pgui.Visible = false end) mouse.Icon = 'rbxassetid://131581677' local friendly = "http://www.roblox.com/asset/?id=131718487" local enemy = "http://www.roblox.com/asset/?id=131718495" local auto = script.Parent.Handle.Auto mouse.Button1Down:connect(function() if auto.Value == false then local name = gun.Name local distance1 = require(script.ModuleScript) local distance = nil remote:FireServer(gun.Barrel.CFrame.p, mouse.Hit.p, distance,name) end end) -- if its auto local inptSrvc = game:GetService("UserInputService") local name = gun.Name local distance1 = require(script.ModuleScript) local distance = nil local firerate = script.Parent.Handle.FireRate while true do wait(0) if inptSrvc:IsMouseButtonPressed(0) then if auto.Value == true then wait(firerate.Value) local function update() -- pgui:WaitForChild("Maxammo") pgui:WaitForChild("Maxammo") pgui.Maxammo.Text = maxammo.Value pgui.ammoval.Text = ammo.Value if pgui.ammoval.Text == 0 then wait(2) end end -- Whilewait update() remote:FireServer(gun.Barrel.CFrame.p, mouse.Hit.p, distance,name) end end end end)