I’m trying to make blood system that will cast to all clients but the problem is that it doesn’t ignore other player characters it only ignores my character. I tried to add the raycastParams in the server script and made it into a parameter to the FireAllClients and grab it in the local script but the problem is that it spawns under ground and I can’t find solutions in the dev forum. The reason why I’m doing this so I can add a disable button for the blood.
This is the server script that will fire to all clients
local ReplicatedStorage = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.MaxHealth = 5000
character.Humanoid.Health = 5000
local lastHealth = character.Humanoid.Health
local humanoidRootPart = character.HumanoidRootPart
character.Humanoid.HealthChanged:Connect(function(health)
if health < lastHealth then
ReplicatedStorage.Remotes.Blood:FireAllClients()
print("fired")
lastHealth = health
end
end)
end)
end)
This is the Local script for the clients to recieve:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BLOOD_COUNT = 10
local BloodTextures = {
3213415529,
3213415014,
3213416072,
3213414394,
3213416072
}
local character = script.Parent
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local rng = Random.new()
ReplicatedStorage.Remotes.Blood.OnClientEvent:Connect(function()
for i = 1, BLOOD_COUNT do
local rayDirection = rng:NextUnitVector() * 10
local rayOrigin = humanoidRootPart.Position
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
rayParams.FilterDescendantsInstances = {character, workspace.Fx}
rayParams.IgnoreWater = true
local result = workspace:Raycast(rayOrigin, rayDirection, rayParams)
if result then
local pos = result.Position
local normal = result.Normal
local instance = result.Instance
local randomSize = math.random(3, 4)
local part = Instance.new("Part")
part.Size = Vector3.new(randomSize, randomSize, 0.05)
part.Transparency = 1
part.CanCollide = false
part.Material = Enum.Material.SmoothPlastic
part.Anchored = false
local decal = Instance.new("Decal")
decal.Texture = "rbxassetid://" .. BloodTextures[math.random(1 , #BloodTextures)]
decal.Parent = part
decal.Color3 = Color3.fromRGB(117, 0, 0)
local weld = Instance.new("WeldConstraint")
weld.Part0 = instance
weld.Part1 = part
weld.Parent = part
part.CFrame = CFrame.lookAt(pos, pos + normal)
part.Parent = workspace.Fx
game.Debris:AddItem(part, 20)
end
end
end)