#Need help please, trying to make wall disappear when it reaches spot then do it again infinite

1 messages · Page 1 of 1 (latest)

frosty ruin
#

I think you need to do a loop if I am correct

exotic lotus
#

when it reaches target it just keeps going 🙁

frosty ruin
#

Im not really a scripter but imma try to understand the script rq

#

So if I am correct, when the player takes damages, the wall need to be further ?

exotic lotus
#

im trying to make it disappear on this white line

frosty ruin
#

Oh then you need to add transparency and collision

exotic lotus
#

can collide?

#

checked

frosty ruin
#

Yeah but once you want to make the line disappear it need to be so that the player can’t collide with it

exotic lotus
#

i want to make the wall disappear when it reaches that line

#

then reset it and do it just like u said a loop

frosty ruin
#

Yea so you just need to put the wall transparency to 1

#

Then do a while loop if I am correct

exotic lotus
#

think about just like that tsunami wave from the escape game

frosty ruin
#

Huuuum

#

I don’t have it sorry

exotic lotus
exotic lotus
#

@tawny solstice

#

local template = script.Parent
local startCFrame = template.CFrame

-- SETTINGS
local targetPosition = Vector3.new(104.5, 21.914, -747.5) -- CHANGE THIS
local reachDistance = 3
local speed = 350
local respawnDelay = 1

while true do
    -- CLONE WALL
    local o = template:Clone()
    o.CFrame = startCFrame
    o.Parent = template.Parent

    -- DAMAGE
    local debounce = {}

    o.Touched:Connect(function(hit)
        local hum = hit.Parent:FindFirstChild("Humanoid")
        if hum and not debounce[hum] then
            debounce[hum] = true
            hum:TakeDamage(60)
            task.delay(1, function()
                debounce[hum] = nil
            end)
        end
    end)

    -- MOVEMENT
    local attachment = Instance.new("Attachment", o)

    local velocity = Instance.new("LinearVelocity")
    velocity.Attachment0 = attachment
    velocity.MaxForce = math.huge
    velocity.VectorVelocity = o.CFrame.LookVector * -speed
    velocity.Parent = o

    -- WAIT UNTIL IT REACHES TARGET
    local reached = false
    local connection

    connection = RunService.Heartbeat:Connect(function()
        if not o.Parent then
            connection:Disconnect()
            return
        end

        if (o.Position - targetPosition).Magnitude <= reachDistance then
            reached = true
            connection:Disconnect()
            o:Destroy()
        end
    end)

    -- WAIT BEFORE NEXT LOOP
    repeat task.wait(1) until reached
    task.wait(respawnDelay)
end```
#

the wall just keeps going. i want it to disappear once it reaches the target like a loop

tawny solstice
#

try to get the minimum distance

exotic lotus
#

is it an easy fix? if so can u send what u mean

tawny solstice
#

but if you print the distance every heartbeat, you should try to look for the minimum distance when it hits the end

#

from the output

exotic lotus
#

tryna make it disappear on that white line

tawny solstice
#

if its a big wall, the distance will probably exceed the reach distance

exotic lotus
tawny solstice
#

it will include the y axis if you use position

#

maybe

#

@exotic lotus

#
local distance = (Vector3.new(o.Position.X, 0, o.Position.Z) - Vector3.new(targetPosition.X, 0, targetPosition.Z)).Magnitude
if distance <= reachDistance then
  reached = true
  connection:Disconnect()
  o:Destroy()
end
exotic lotus
#

trying irlcry