Post deleted by author .
Post deleted by author
Perhaps, just giving ideas here, you can use the .Touched and .TouchEnded functions to handle these events than a Region 3 check could.
So you could give a player a weapon, and then once any player left the zone, check if they have a sword in their backpack, and delete it.
Example:
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Checking if a player touched the box
if player then
if player.Backpack:FindFirstChild("Sword") == nil then -- Checking if the player already owns the weapon.
local sword = script.Sword:Clone() -- Giving the player the weapon.
sword.Parent = player.Backpack
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Checking if a player went out of the box.
if player then
local sword = player.Backpack:FindFirstChild("Sword")
if sword then -- Checking if the player owns the weapon.
sword:Destroy() -- Removing the weapon
end
end
end)
1 Like
Glad I could help! Keep in mind though that Region3 could lag the game with too many functions, so try to optimize it as much as you can.
1 Like