I’d recommend using :FindFirstAncestorOfClass(“Model”)
local Players = game:GetService("Players");
script.Parent.Parent.TouchDec.Touched:Connect(function(Touch1)
local Model1 = Touch1:FindFirstAncestorOfClass("Model");
local Player1 = if Model1 then Players:GetPlayerFromCharacter(Model1) else nil;
if Player1 then -- you want to double check and make sure it's a valid player before moving forward
-- C1 can just be replaced with Model1 no reason to make a new variable
end
end)
the same logic should be applied for C2, and I wouldn’t put them both in the same logical process
Player2 wouldn’t have a LocalPlayer, the only time LocalPlayer exists is from a client view and it’s an attribute/property of the Players service itself not a Player object.
It’s entirely dependent on what the .Touch is hitting, if it first hits an accessory part then .Parent wouldn’t be the character model i.e it wouldn’t be able to pull a player from it → which is why I recommended FindFirstAncestorOfClass it ensures that it grabs the closest top instance of class model (the only time this may cause issues is if you have models of parts inside the player model)
I found a solution I just made and if statement to check if the touch is a HRP so I make sure that touch.parent is the character also siren solution still works so I will mark his reply as a solution