For reference, I am using the provided method for creating projectiles with zero latency. I understand how it works (at least I thought I did), but when I try to apply it to my own project, I am met with many roadblocks. One big problem in particular is how my projectile refuses to replicated into my tool’s Buffer folder when play testing. I have been debugging for hours and it quite literally will disappear after the code is through. I have no idea what I’ve done wrong, nor do I have any alternative in my mind to my problem of creating projectiles that handle a server-client relationship. Any advice would be greatly appreciated.
Server script
local Players = game:GetService("Players")
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Resources = require(script.Parent:WaitForChild("Resources"))
local BoltCreator = require(Resources:GetResource("BoltCreator"))
local RemoteCreator = require(Resources:GetResource("RemoteCreator"))
local BufferCreator = require(Resources:GetResource("BufferCreator"))
local Configuration = require(Resources:GetResource("Configuration"))
local BoltBuffer = BufferCreator:CreateServerBuffer("BoltBuffer")
local CastBoltEvent = RemoteCreator:CreateRemoteEvent("CastBolt")
local BASIC_ATTACK_CD = Configuration.BASIC_ATTACK_CD
local CurrentCharacter,CurrentPlayer
local CurrentBolt
local Equipped = false
local function AddBufferBolt() --Adds model to buffer (ISSUE)
local NewBolt = BoltCreator.CreateBolt(true)
CurrentBolt = NewBolt
BoltBuffer:AddItem(CurrentBolt)
end
AddBufferBolt()
Buffer function in question:
function Buffer:AddItem(NewItem)
NewItem.Parent = BufferFolder
local Obj = (NewItem:IsA("BasePart") and NewItem) or (NewItem:IsA("Model") and NewItem) or NewItem:FindFirstChildWhichIsA("BasePart",true)
if Obj then
--Add a position lock.
local HoldPos = Vector3.new(math.random(-1000,1000),100000,math.random(-1000,1000))
if Obj:IsA("Model") then
Obj:SetPrimaryPartCFrame(CFrame.new(HoldPos))
local PositionLock = Instance.new("BodyPosition")
PositionLock.Position = HoldPos
PositionLock.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
PositionLock.Name = "BufferPositionLock"
PositionLock.Parent = Obj.PrimaryPart
--Set the network ownership to the client so it can control physics.
if Obj:IsDescendantOf(game.Workspace) and not Obj.PrimaryPart.Anchored and Player then
Obj.PrimaryPart:SetNetworkOwner(Player)
end
elseif Obj:IsA("BasePart") then
Obj.CFrame = CFrame.new(HoldPos)
local PositionLock = Instance.new("BodyPosition")
PositionLock.Position = HoldPos
PositionLock.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
PositionLock.Name = "BufferPositionLock"
PositionLock.Parent = Obj
--Set the network ownership to the client so it can control physics.
if Obj:IsDescendantOf(game.Workspace) and not Obj.Anchored and Player then
Obj:SetNetworkOwner(Player)
end
end
end