I want to make players go to the spawn location and the walls reappear after the player touches the part, they go to the spawn and walls appear but when the player does it again the walls don’t reappear.
local part = script.Parent
local walls = game.Workspace.Walls:GetChildren()
local spawnlocation = game.Workspace.SpawnLocation
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild(“Humanoid”)
if humanoid then
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 5
part.CanTouch = false
player.Character:SetPrimaryPartCFrame(spawnlocation.CFrame)
part.CanTouch = true
for _, v in pairs(walls) do
v.Parent = game.Workspace
end
end
end
To clarify, there is a part you want them to touch, when they touch it, walls are supposed to appear, when they touch it again they are supposed to disappear, right?
local part = script.Parent
local spawnlocation = game.Workspace.SpawnLocation
local db = false;
local function onTouch(otherPart)
if (db == true) then
return;
end;
db = true;
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 5
part.CanTouch = false
player.Character:SetPrimaryPartCFrame(spawnlocation.CFrame * CFrame.new(0, player.Character:GetExtentsSize().Y, 0))
part.CanTouch = true
for _, wall in pairs(workspace.Walls:GetChildren()) do
wall.CanCollide = not wall.CanCollide;
wall.Transparency = wall.CanCollide and 0 or 1
end
end
end
task.wait(2)
db = false
end
part.Touched:Connect(onTouch)