Hi guys, it's since 2 weeks that I'm trying to resolve this problem, what I want to do is to "check" the corpse of a player while who's checking is the detective, this works but what I REALLY want to do is: If the player has the mouse over my ClickDetector AND is in a distance of 6 studs between the player and the corpse AND the player pressed "E" then do.... But it works like this "if statement" is ignored...
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local pInfo = script.Parent.PlayerInfo.Wrapper
local target = script.Parent.Parent -- The corpse
function func_1637702a() -- Obfuscation ftw
-- hide the corpse (transparency => 0) and spawn barrel
end
function keyPress(par1)
if par1 == "e" then
local td = player:FindFirstChild("TempData")
local tp = td:FindFirstChild("Type")
if player:DistanceFromCharacter(target.Torso.Position) <= 6 then
if tp.Value == "Traitor" then
if pInfo.HealthStatus.Text == "Corpse" then
func_1637702a()
else
print("The traitor tried to hide an alive player")
end
else
print("A player tried to hide a corpse while not being a traitor")
end
end
end
end
mouse.KeyDown:connect(keyPress)
I want to use the method "MouseHoverEnter" but this will work only the function on mouse hover the clickdetector, and this function it's called when the player presses "e", so I need to check if the mouse is STILL on the clickdetector and I don't know how to do that, thanks for helping!
