so uhh I want to make an area(part that has no cancolide on) that gives the player a sword(basically adding the tool to the player which i tried in client view when playing before) and deletes it when the player leaves the area(part)
i suck at script so no idea how to use a script to solve the problem so I need some help
Thanks
2 Likes
I already had a place like this so I’m going to share it. here is a simple loop to check if the player is touching the part or not I don’t know if this is the best way but it works perfectly fine for me. put this in a server script inside serverscriptservice
im sure you can just tweak the variables to get it working but im still going to share a place file Arena.rbxl (28.6 KB)
wait(5)
while wait() do
local hitbox = workspace:FindFirstChild("SwordPart")
local connection = hitbox.Touched:Connect(function() end) -- just so it works with cancollide off
local touching = hitbox:GetTouchingParts()
connection:Disconnect()
for i, v in pairs(game.Players:GetChildren()) do
local char = v.Character or v.CharacterAdded:Wait()
local thing = char:WaitForChild("HumanoidRootPart")
if table.find(touching, thing) then
if not v.Backpack:FindFirstChild("Sword") and not char:FindFirstChild("Sword") then
local clone = game.ReplicatedStorage.Sword:Clone()
clone.Parent = char
end
else
local a = v.Backpack:FindFirstChild("Sword")
local b = char:FindFirstChild("Sword")
if a then a:Destroy() end
if b then b:Destroy() end
end
end
end
3 Likes