Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't my projectile replicating properly?

Asked by 4 years ago
Edited 4 years ago

So I'm pretty new to projectile replication and how to get projectiles to properly replicate to all clients from the server. So far the things I've done seem to be working except for one major issue that comes with determining a player's mouse position. In this bit of code I have the player fire a barrage of arrows. The move works perfectly fine on the client that has initiated the attack but on every other client that can see the attack or is taking damage from the attack the projectiles just float off into space instead of going towards where the attacking player has pointed their mouse.

Here is the code:

for i = 1, 10 do
wait(0.1)
local Blast = game.ReplicatedStorage.AttackThings.Archer.Arrow:Clone()
Blast.Parent = player.Character.AttackParts.Things
Blast.CFrame = player.Character.HumanoidRootPart.CFrame*CFrame.new(0, 0, -1)
Blast.Anchored = false
Blast.CanCollide = false
game.Debris:AddItem(Blast, 3)
local BV = Instance.new("BodyVelocity")
    BV.Parent = Blast
    BV.maxForce = Vector3.new(math.huge, math.huge, math.huge)
    local MousePos = player:GetMouse().Hit.p --This is the issue here
    local direction = -(Blast.Position - MousePos)
    BV.Velocity = direction.unit * 100 

This is a local script that each client can access. The server tells each client to replicate a certain attack and then those clients reference this code to create the attack. I know I probably didn't do a good job of describing the issue but if you need more description please just ask. I really need some help with this problem.

0
please include the entire code and what type of script this is Gameplayer365247v2 1055 — 4y
0
Two words, Network Filtering theking48989987 2147 — 4y

Answer this question