#Gun still damages the local player
10 messages · Page 1 of 1 (latest)
This gun still damages me when I shoot -
** You are now Level 4! **
Local Script -
local Part = script.Parent
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local RS = game:GetService("ReplicatedStorage")
local RM = RS.RemoteEvent
------
local Tool = script.Parent.Parent.Parent
local Tip = script.Parent
Mouse.Button1Down:Connect(function()
local character = Player.Character
if character and character:FindFirstChild("Gun") then
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {Player.Character, script.Parent}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local rayOrigin = Part.Position
local rayDestination = Mouse.Hit.p
local rayDirection = rayDestination - rayOrigin
RM:FireServer(rayOrigin, rayDirection, Tool, raycastParams, Tip)
--print("Equipped")
else
print("Not Yet Equipped!")
end
end)
Server Script -
local RS = game:GetService("ReplicatedStorage")
local RM = RS.RemoteEvent
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Bullet = RS.Bullet
RM.OnServerEvent:Connect(function(player, rayOrigin, rayDirection, Tool, raycastParams, Tip)
print(player,"fired the event.")
local damage = Tool:GetAttribute("Damage")
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
---- Sound
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://1905367471"
sound.Parent = Tool
sound:Play()
if raycastResult then
print(raycastResult.Instance.Name)
local PartHit = raycastResult.Instance.Parent
if PartHit:FindFirstChild("Humanoid") then
print("Found Humanoid")
local humanoid = PartHit:FindFirstChild("Humanoid")
humanoid:TakeDamage(damage)
end
if PartHit == "Head" then
print("Headshot!")
end
end
end)
Gun still damages the local player
I filtered it out thought so im confused
raycastParams.FilterDescendantsInstances = {Player.Character, script.Parent}
Someone help