#Gun still damages the local player

10 messages · Page 1 of 1 (latest)

cunning fog
#

I mean do you want the shot to be instant or

#

it depends on what you're making

wispy cloak
#

This gun still damages me when I shoot -

rapid deltaBOT
#

studio** You are now Level 4! **studio

wispy cloak
#

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}

wispy cloak
#

Someone help