#how can i make bullets server sided without any delay, ts pmo💔

1 messages · Page 1 of 1 (latest)

trail meadow
#
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")

local player = Players.LocalPlayer
local tool = script.Parent
local bodyAttach = tool:WaitForChild("BodyAttach")
local muzzle = bodyAttach:WaitForChild("Muzzle")
local fireRemote = ReplicatedStorage:WaitForChild("FireGun")
local replicateBulletRemote = ReplicatedStorage:WaitForChild("ReplicateBullet")
local Config = require(tool:WaitForChild("Config"))
local bulletTemplate = ReplicatedStorage:WaitForChild("Misc"):WaitForChild("Gunstuff"):WaitForChild("projectiles"):WaitForChild("Bullet")
local lastShotTime = 0

local function CreateBullet(origin, direction)
    local bullet = bulletTemplate:Clone()
    bullet.Position = origin
    bullet.Anchored = false
    bullet.CanCollide = false
    bullet.CanQuery = false
    local bodyVelocity = Instance.new("BodyVelocity")
    bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    bodyVelocity.Velocity = direction * Config.GunSettings.BulletSpeed
    bodyVelocity.Parent = bullet
    bullet.Parent = workspace
    Debris:AddItem(bullet, 5)
end

local function OnActivated()
    if not tool.Enabled then return end
    local currentTime = tick()
    if currentTime - lastShotTime < Config.GunSettings.FireRate then return end
    lastShotTime = currentTime
    local mouse = player:GetMouse()
    local mousePos = mouse.Hit.Position
    local origin = muzzle.WorldPosition
    local direction = (mousePos - origin).Unit
    CreateBullet(origin, direction)
    fireRemote:FireServer(mousePos)
end

replicateBulletRemote.OnClientEvent:Connect(function(shooter, origin, direction)
    if shooter ~= player then
        CreateBullet(origin, direction)
    end
end)

tool.Activated:Connect(OnActivated)

local script

#

heres the server script

tulip reef
#

There is no way to remove delay unless you invent a way to move data faster than the speed of light.

Every game has delay and what they do to not make it apparent is to fake stuff. For example if you shoot a gun, it will appear instantly on your screen with a bullet tracer. On your screen the player will pretend it shot and hit someone

Server checks if the hit is valid and if not it tells the client and the client goes "back in time" or undoes the hit

gentle rock
#

Its impossible

#

Every popular game with a smooth gun system creates their bullets clientsided

trail meadow
#

oh

#

ive seen some games with smooth bullet thingies and i thought it was possible