Sorry, but it didn’t work, I tried rendering fastcast bullets and doing everything on the client, but that just made it much worse, here is a video showing the performance:
I spent several days working on this, I am tired, I don’t know what to do, I made a topic about this as you saw and it didn’t get any replies for a week, here is the script:
--edit: this is a local script
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Remotes = ReplicatedStorage.Events
local Event = Remotes[script.Name]
local FastCast = require(ReplicatedStorage.FastCastRedux)
local PartCache = require(ReplicatedStorage.PartCache)
ReplicatedStorage.Events.FastCastClient.OnClientEvent:Connect(function(NPC,Type,attachment,direction,velocity)
if Type == 'Constructor' then
local Caster = FastCast.new()
local behaviour = Caster.newBehavior()
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {NPC,workspace.Projectiles,workspace.OreSpawningArea}
local bulletTemplate = Instance.new('Part')
bulletTemplate.Size = Vector3.new(0.2,0.2,12)
bulletTemplate.Material = Enum.Material.Neon
bulletTemplate.Color = Color3.fromRGB(255, 225, 0)
bulletTemplate.CanCollide = false
local CachedBullet = PartCache.new(bulletTemplate,100,workspace.Projectiles)
behaviour.RaycastParams = raycastParams
behaviour.MaxDistance = 300
behaviour.AutoIgnoreContainer = false
behaviour.CosmeticBulletContainer = workspace.Projectiles
behaviour.CosmeticBulletProvider = CachedBullet
Caster.LengthChanged:Connect(function(cast,lastpoint,direction,length,velocity,bullet)
if bullet then
local bulletlength = bullet.Size.Z/2
local offset = CFrame.new(0,0,-(length - bulletlength))
bullet.CFrame = CFrame.lookAt(lastpoint,lastpoint + direction):ToWorldSpace(offset)
end
end)
Caster.CastTerminating:Connect(function(cast)
local cosmeticBulletObject = cast.RayInfo.CosmeticBulletObject
if cosmeticBulletObject ~= nil then
CachedBullet:ReturnPart(cosmeticBulletObject)
end
end)
Caster.RayHit:Connect(function(cast,result,velocity,bullet)
local enemyHum = result.Instance:FindFirstAncestorWhichIsA('Model'):FindFirstChild('Humanoid')
if enemyHum and result.Instance:FindFirstAncestorWhichIsA('Folder').Name == 'Allies' then
ReplicatedStorage.Events.FastCastClient:FireServer(enemyHum,5)
end
end)
function Fire(firepointAttachment,direction,velocity)
Caster:Fire(firepointAttachment.WorldPosition,direction,velocity,behaviour)
end
elseif Type == 'Fire' then
Fire(attachment,direction,velocity)
end
end)
I am stuck, I have no clue what i’m doing wrong, I tried doing partcache on the server and sending it to the client, it didn’t work, I tried doing things on the server and only doing rendering parts on the client, it didn’t work, I have no clue what to do, please advise me on things I can do to get an answer on this issue, how to write a dev forum post better so that it gets a reply, I just want to get this thing done