Hi, since I'm making a TTT game I need to make a function that hide a player corpse in a barrel, already done that. This function is triggered if the player press E (ok) and if the player distance radius from the corpse is 2-3 but I don't know how!. This is the code in a LocalScript, which his Parent contains a ClickDetector to get the corpse, easy:
local player= game.Players.LocalPlayer
local mouse = player:GetMouse()
local pInfo = script.Parent.PlayerInfo.Wrapper
local target = script.Parent-- The corpse
local hid = false
function func_1637702a()
-- hide the corpse (transparency => 0) and spawn barrel
end
function keyPress(par1)
if par1 == "e" and hid == false then
local td = player:FindFirstChild("TempData")
local tp = td:FindFirstChild("Type")
--if player radius position <= corpse radius position by 2 then
if type.Value == "Traitor" then
if pInfo.HealthStatus.Text == "Corpse" then
func_1637702a()
hid = true
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)
Thanks for helping me!

1 comment
Ok thanks, I understand all thanks to Phisic xD, anyway I now test that