How do I make a tool only appear when inside an area

I am making a swordfighting game and in my game there’s a training area where I want the player to be able to equip their sword (a tool) while in it and use it to attack the dummies. How could I make the tool only appear when inside it?
Tried a touch event but it was pretty inconsistent

Here’s an image to illustrate if I wasn’t clear enough

Could use a zone module or make your own region3 script, all you would do is put the tool in their backpack and EquipTool() when they enter the zone and then UnequipTools() when they leave.

Touch event should work perfectly fine, just make sure to use a debounce so it doesn’t mess up

I used this script with touch events but when I tested it the sword kept appearing and disappearing when equipping it

local trainSword = game.ServerStorage:WaitForChild("BegSword"):Clone()
local area = script.Parent

if area then
	area.Touched:Connect(function(hit)
		local char = hit.Parent
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr and char.Name == plr.Name then
			if not plr.Backpack:FindFirstChild("BegSword") and not char:FindFirstChild("BegSword") then
				trainSword.Parent = plr.Backpack
			end
		end
		print(trainSword.Parent)
	end)

	area.TouchEnded:Connect(function(hit)
		local char = hit.Parent
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr and char.Name == plr.Name then
			if plr.Backpack:FindFirstChild("BegSword") or char:FindFirstChild("BegSword") then
				trainSword.Parent = nil
			end
		end
		print(trainSword.Parent)
	end)
end

Try using a region 3 or something like ZonePlus

Solved this using bounding boxes, thanks for the help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.