I have a drop bomb system where a fighter jet drops bombs when the player presses R on their keyboard. When I spawn the bomb on the client, it spawns at the exact cframe as the spawner but on the server, I set the network ownership to the player but it spawns further away from the spawner? How can I fix this?
Client:
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local model = script.Parent
local VehicleSeat = model:WaitForChild("VehicleSeat")
local cooldown = 0.5
local currentTime = cooldown
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed and input.KeyCode == Enum.KeyCode.R then
if VehicleSeat.Occupant then
local result = game.Players:GetPlayerFromCharacter(VehicleSeat.Occupant.Parent)
if result and tick() - currentTime >= cooldown then
currentTime = tick()
script.DropBomb:FireServer()
end
end
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Bomb = ReplicatedStorage:WaitForChild("Bomb")
local model = script.Parent.Parent
local BombSpawner = model:WaitForChild("BombSpawner")
local function SetNetworkOwner(modelToSet, owner)
for i,v in ipairs(modelToSet:GetDescendants()) do
if v:IsA("BasePart") then
local result = v:CanSetNetworkOwnership()
if result then
v:SetNetworkOwner(owner)
end
end
end
end
local function DropBomb(player)
local newBomb = Bomb:Clone()
newBomb:PivotTo(BombSpawner.CFrame)
newBomb.Parent = workspace
SetNetworkOwner(newBomb, player)
end
script.Parent.DropBomb.OnServerEvent:Connect(function(player)
DropBomb(player)
end)