Hey everyone,
Again. the first one that touches the part is the one that is detected by the touch event - without the player itself
Again. the first one that touches the part is the one that is detected by the touch event - without the player itself with the palyer itself I mean the player.character
so for example when the first one of 100 hits the part it will just get the first one.
but let it us say the first one is the humanoid, then it the touchevent even wont hit anything
this above is the best explanation you can get!!!
I have a big problem and that is: I want make a detection but just for 2 players. me and the humanoid I hitted and when the firstplayer gets hit - without me - then the Gui pops on his Screen.
But with my script I have a big issue and that is, that my touch event detects me and also it does detect me as first humanoidrootpart what it shouldnt do.
Here a video to visualize everything better:
if you still didnt understand what happen in the video let me explain you: The Player2 gets the Gui and that shoudnt happen before he doesnt touch the part, it seems like the Player1 activate the touchevent, and that is a big issue we have to fix.
local base = game.Workspace:WaitForChild("Baseplate")
local connection
local touched = false
game.Players.PlayerAdded:Connect(function(player)
connection = base.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and touched == false
and hit ~= player.Character and not hit:IsDescendantOf(player.character)then
touched = true
local hitted = hit.Parent
local HumanoidRootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
local HumanoidNPC = hit.Parent:FindFirstChild("Humanoid")
local plr2 = game.Players:GetPlayerFromCharacter(hitted)
local EHumanoidP = HumanoidRootPart.Position
local Clone1 = script.AttackCollection:Clone()
local Clone2 = script.AttackCollection:Clone()
Clone1.Parent = player.PlayerGui
Clone2.Parent = plr2.PlayerGui
Clone2.Enabled = true
Clone1.Enabled = true
local Player = hit.Parent
connection:Disconnect()
end
end)
end)