local replicatedStorage = game:GetService("ReplicatedStorage")
local weaponRemoteEvents = replicatedStorage.remoteEvents.weaponRemoteEvents
weaponRemoteEvents.shootEvent.OnServerEvent:Connect(function(player, mousePos, bulletTravelDistance, toolHandle, damage, toolName)
local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {player.Character}
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
local ray = workspace:Raycast(toolHandle.CFrame.p, (mousePos - toolHandle.CFrame.p) * bulletTravelDistance, rayParams)
if ray then
local model = ray.Instance:FindFirstAncestorOfClass("Model")
if model then
if model:FindFirstChild("Humanoid") then
model.Humanoid.Health -= damage
end
end
end
end)
Here is the code for the gun. I've tried so many ways to get a working visualizer but I just can't seem to get it to work. Please help. Also here are what the params are:
player = local player
mousePos = player:GetMouse().Hit
bulletTravelDistance = 300
toolHandle = toolHandle part
damage = 10
toolName = ar

3 comments
isn't lerp deprecated? maybe just subtract the startpoint by half of the hitpoint
I believe :Lerp() was to be deprecated in the context of animation, with the replacement being tweens.
local middlePos = Part1.Position:Lerp(Part2.Position, 0.5) but there is also a more efficient solution