Roblox Studio - How To Make Teleporters [Feat. Module Script]
Автор: Kinfolk Studio
Загружено: 2021-08-12
Просмотров: 124
This video shows you how to make teleporters in Roblox Studio, with a brief introduction of Module Script.
TeleportModule (in Server Script Service):
local module = {}
function module.TeleportPlayer(Player, Destination)
if Player and Destination and game.Players:FindFirstChild(Player.Name) then
local Char = Player.Character
if Char.PrimaryPart then
Char:SetPrimaryPartCFrame(CFrame.new(Destination + Vector3.new(0,4,0)))
end
end
end
function module.TeleportPlayerLookAt(Player, Destination, LookAt)
if Player and Destination and LookAt and game.Players:FindFirstChild(Player.Name) then
local Char = Player.Character
if Char.PrimaryPart then
Char:SetPrimaryPartCFrame(CFrame.lookAt(Destination + Vector3.new(0,4,0), LookAt))
end
end
end
return module
Teleport (in Teleporter part):
local ServerScriptService = game:GetService("ServerScriptService")
local TeleportModule = require(ServerScriptService:WaitForChild("TeleportModule"))
local Teleporter = script.Parent
local Destination = script.Parent.Parent:WaitForChild("Destination")
local DB = false
Teleporter.Touched:Connect(function(who)
if DB == false then
DB = true
if who and who.Parent and who.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(who.Parent)
if Player then
TeleportModule.TeleportPlayer(Player, Destination.Position)
end
end
DB = false
end
end)
Teleport with LookAt (in Teleporter part):
local ServerScriptService = game:GetService("ServerScriptService")
local TeleportModule = require(ServerScriptService:WaitForChild("TeleportModule"))
local Teleporter = script.Parent
local Destination = script.Parent.Parent:WaitForChild("Destination")
local LookAt = script.Parent.Parent:WaitForChild("LookAt")
local DB = false
Teleporter.Touched:Connect(function(who)
if DB == false then
DB = true
if who and who.Parent and who.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(who.Parent)
if Player then
TeleportModule.TeleportPlayerLookAt(Player, Destination.Position, LookAt.Position)
end
end
DB = false
end
end)
![Roblox Studio - How To Make Teleporters [Feat. Module Script]](https://ricktube.ru/thumbnail/s33TMdsoiFc/hq720.jpg)
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: