i know there’s loads of topics on this but i just can’t seem to get it.
im trying to retrieve my otherplr variable from the top function but im not sure how to do it. i appreciate any help
pickupPlayerEvent.OnServerEvent:Connect(function(myPlr, myHRP:MeshPart)
for _, otherPlr in ipairs(game.Players:GetPlayers()) do
local otherCharacter = otherPlr.Character
if myPlr == otherPlr then continue end
if not otherCharacter then continue end
local otherHRP:MeshPart = otherCharacter:WaitForChild("HumanoidRootPart")
if not otherHRP then continue end
local dist = (otherHRP.Position - myHRP.Position).Magnitude
if dist < 10 then
print(string.format("%s is close (%f studs away)", otherPlr.Name, dist))
local module = require(script.pickupModule)
module.stallPlayer(otherPlr)
wait()
module.createWeld(otherPlr, myPlr.Character)
end
end
end)
DropPlayerEvent.OnServerEvent:Connect(function(myPlr)
local module = require(script.pickupModule)
module.dropPlayer(otherplr, myPlr)
end)
local currentPlr = nil
pickupPlayerEvent.OnServerEvent:Connect(function(myPlr, myHRP:MeshPart)
for _, otherPlr in ipairs(game.Players:GetPlayers()) do
local otherCharacter = otherPlr.Character
if myPlr == otherPlr then continue end
if not otherCharacter then continue end
local otherHRP:MeshPart = otherCharacter:WaitForChild("HumanoidRootPart")
if not otherHRP then continue end
currentPlr = otherPlr
local dist = (otherHRP.Position - myHRP.Position).Magnitude
if dist < 10 then
print(string.format("%s is close (%f studs away)", otherPlr.Name, dist))
local module = require(script.pickupModule)
module.stallPlayer(otherPlr)
wait()
module.createWeld(otherPlr, myPlr.Character)
end
end
end)
DropPlayerEvent.OnServerEvent:Connect(function(myPlr)
if currentPlr then
local module = require(script.pickupModule)
module.dropPlayer(otherplr, myPlr)
end
end)