Adding a Rolling Boulder Trap In Roblox Studio

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ม.ค. 2025

ความคิดเห็น • 4

  • @JR-kd2sh
    @JR-kd2sh 6 หลายเดือนก่อน

    Is there a way to make it so that you don't need a trigger for the rock to fall, and instead fall down at certain time intervals?

  • @bloxbirds6859
    @bloxbirds6859 ปีที่แล้ว +1

    Just subbed but I have a question, im trying to learn lua myself but I dont know where to learn it so if you have any tips it would help

  • @hyper-2308
    @hyper-2308 หลายเดือนก่อน

    that a.i thumbnail tho😂

  • @nobelcourses
    @nobelcourses  ปีที่แล้ว

    Script:
    local trap = script.Parent
    local trigger = trap.Trigger
    local door = trap.Door
    local rock = trap.Rock
    local resetPart = trap.Reset
    local rolling = false
    local function reset()
    door.Transparency = 0 -- Change to 1 for door transparency after player hits the trigger
    door.CanCollide = true
    rock.Position = resetPart.Position + Vector3.new(0, rock.Size.Y/2,0)
    rock.Anchored = true
    rock.Velocity = Vector3.new(0,0,0)
    end
    local function release (otherPart)
    local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
    if humanoid and not rolling then
    rolling = true
    door.Transparency = 1
    door.CanCollide = false
    rock.Anchored = false
    wait(3) -- Number of seconds before rock resets
    reset()
    rolling = false
    end
    end
    local function crush(otherPart)
    local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
    if humanoid then
    humanoid.Health = 0
    wait(1)
    reset()
    end
    end
    trigger.Touched:Connect(release)
    rock.Touched:Connect(crush)