I’m trying to replicate a knife to all players except the LocalPlayer
The issue is that the function works and all, I’ve tested it but it still not replicating to any clients at all in an actual server, there’s nothing cloning in the Debris folder I made and I have no idea how to go about fixing this issue
Client Script:
ReplicateThrow.OnClientEvent:Connect(function(player, pos, dir, speed)
if isEventConnected then
return
end
isEventConnected = true
local KnifeModel = AssetsFolder:WaitForChild("Knife")
local FakeKnife = KnifeModel:Clone()
FakeKnife.Name = "FakeKnife"
FakeKnife.Parent = workspace.Debris
FakeKnife.Transparency = 0
FakeKnife.CFrame = CFrame.new(pos, pos + dir)
FakeKnife.Velocity = dir * speed
local fakeHitbox = RaycastHitbox.new(FakeKnife)
fakeHitbox.DetectionMode = RaycastHitbox.DetectionMode.PartMode
fakeHitbox:HitStart()
fakeHitbox.OnHit:Connect(function(hit, _, raycastResult)
local normal = raycastResult.Normal
local position = raycastResult.Position
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid.Parent == Character then
return
end
-- Ignore collisions with parts belonging to the player's character
local isPlayerCharacter = false
for _,part in pairs(Character:GetDescendants()) do
if part == hit then
isPlayerCharacter = true
break
end
end
if isPlayerCharacter then
return
end
FakeKnife.Velocity = Vector3.new(0, 0, 0)
FakeKnife.Anchored = true
FakeKnife.Position = position
debounce = false
task.wait(2)
FakeKnife:Destroy()
return
end)
print(KnifeSpeed)
print(direction)
print(position)
end)
ReplicateThrow:FireServer(position, direction, KnifeSpeed)
Server Script:
function bounceRemote(player, pos, dir, speed)
for i,v in ipairs(game.Players:GetPlayers()) do --getting all the players in the game
if v ~= player then
warn("Player who sent: " .. tostring(player) .. "\n Player who Recieved:" .. tostring(v) .. "\n Other Variables:" .. tostring(pos), tostring(dir), tostring(speed)) --all players BUT the one who blew it, (they already ran it on the client in the earlier code at blowBubble(player) after BlowEvent:FireServer()
ReplicateThrow:FireClient(v, player, pos, dir, speed)
end
end
end
ReplicateThrow.OnServerEvent:Connect(bounceRemote)
it’ll be much appreicated if someone helps me with this problem