My script detects Players but I 'm trying to get the (hit) to not detect Mainplayer
part.Touched:Connect(Function(hit) if hit ~= Mainplayer then ----- script end)
There is a function called GetPlayerFromCharacter(Char)
of players that gets the player object from the given character model.
local mainPlayer = game.Players:GetPlayerFromCharacter(script.Parent) part.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then -- check if player is a character local character = hit.Parent local player = game.Players:GetPlayerFromCharacter(character) if player ~= mainPlayer then -- do this if the player is someone else other than the main player end end end)
Hope this helps, if you have any questions please let me know!