I’ve been trying to find a solution to this problem of mine but to no avail. I’ve browsed through a dozen of DevForum posts that had solutions that didn’t work for me and thought I might as well make a post myself.
local replicatedStorage = game:GetService("ReplicatedStorage")
local gunService = replicatedStorage.GunService
local serverScriptService = game:GetService("ServerScriptService")
local userInputService = game:GetService("UserInputService")
local starterGui = game:GetService("StarterGui")
gunService.RemoteEvents.FireBullet.OnServerEvent:Connect(function(player,handle,mousePos)
local rayOrigin = handle.FirePoint.Position
local rayDirection = (mousePos- rayOrigin).Unit
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances =
{ player.Character,
workspace.Baseplate
}
print(raycastParams.FilterDescendantsInstances)
local raycastResult = workspace:Raycast(rayOrigin, rayDirection*300)
if raycastResult then
local hitPart = raycastResult.Instance
print(hitPart)
hitPart:Destroy()
end
end)
Firing the ray works fine, and deletes whatever it lands on but sometimes it has this problem where it just hits the character and deletes their limbs.
I figured this would be an easy job for RaycastParams.FilterDescendantsInstances
, yet the array I’ve added isn’t taken to consideration and things included in it like the workspace’s baseplate gets destroyed either way.
Note, this is a server script, RemoteEvent
fired by a local script which I can send the code of if needed.
Any kind of help will be greatly appreciated.
also first forum post i’ve ever made hello everyone