Roblox Studio Tutorial: Secret Doorway (Touch)
: Open a doorway by touching a part near the door
- lift up function
```
local part = script.Parent
local wall = game.Workspace.Wall
local canOpen = true
local function lift(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA('Humanoid')
if humanoid and canOpen then
canOpen = false
wall.Position = wall.Position + Vector3.new(0,12,0)
wait(3)
wall.Position = wall.Position + Vector3.new(0,-12,0)
canOpen = true
end
end
part.Touched:Connect(lift)
```
-- disapear
```
local part = script.Parent
local wall = game.Workspace.Wall.DoorWall
local canOpen = true
-- Make Wall Go Disapear
local function disapear(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA('Humanoid')
if humanoid and canOpen then
canOpen = false
wall.Transparency = 1
wall.CanCollide = false
wait(3)
wall.Transparency = 0
wall.CanCollide = true
canOpen = true
end
end
part.Touched:Connect(disapear)
```
Roblox Studio Tutorial: Pay to Open Door
```
local part = script.Parent
local wall = game.Workspace.Wall.PayWall
local canOpen = true
local sound = part["Door Opening"] --var for sound
local openDistance = 12 --height the door goes up
local steps = 10 --number of steps door take (more = smoother)
local stepSize = openDistance / steps --distance for each step
local function liftSmoothPayCheck(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA('Humanoid')
if humanoid and canOpen then
-- Moeny check
local player = game.Players:FindFirstChild(partParent.Name)
if player and player.leaderstats.Money.Value >= 100 then
player.leaderstats.Money.Value = player.leaderstats.Money.Value - 100
canOpen = false
sound:Play() --plays sound
part.BrickColor = BrickColor.new('Lime green') --changes color
--opens door
for i = 1, steps do
wall.Position = wall.Position + Vector3.new(0,stepSize,0)
wait()
end
--wait time before close
wait(2)
--closes door
for i = 1, steps do
wall.Position = wall.Position - Vector3.new(0,stepSize,0)
wait()
end
part.BrickColor = BrickColor.new('Really red') --changes color
canOpen = true
end
end
end
--part.Touched:Connect(lift)
--part.Touched:Connect(liftSmooth)
part.Touched:Connect(liftSmoothPayCheck)
--part.Touched:Connect(disapear)
```
Roblox Studio Tutorial: Open Door with Key
```
local part = script.Parent
local wall = game.Workspace.Wall.KeyWall
local canOpen = true
local function lift(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid and canOpen then
local player = game.Workspace:FindFirstChild(partParent.Name)
if player then
if player:FindFirstChild('Key') then
canOpen = false
wall.Transparency = 1
wall.CanCollide = false
local key = player:FindFirstChild('Key')
key.Parent = game.Workspace
key.Handle.Position = Vector3.new(math.random(-100,100),5,math.random(-60,-10))
wait(2)
wall.Transparency = 0
wall.CanCollide = true
canOpen = true
end
end
end
end
part.Touched:Connect(lift)
```
'tech > game' 카테고리의 다른 글
21/07/31 Roblox Studio Tutorial: How to Make a Pop-up Menu (0) | 2021.07.31 |
---|---|
21/07/31 How To Play ROBLOX In VR!! (0) | 2021.07.31 |
21/07/31 Roblox Custom Animation (Player) (0) | 2021.07.31 |
21/07/31 Roblox Studio Tutorial (How To Change Player Sprint Speed) (0) | 2021.07.31 |
21/07/31 HOW TO MOVE PLAYERS (0) | 2021.07.31 |