Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is anyone willing to teach a complete noob the scripting language "Lua?"

Currently, I'd say I have some experience with coding but nothing along the lines of lua. Therefore, I'm reaching out if anyone is willing to teach this noob lua? I have no robux in hand so I can't really pay. Also I would prefer if we did it over a voicing app like Discord.

2 comments

0

https://scriptinghelpers.org/questions/28975/how-to-start-scripting#32412 lists a number of lua-related resources. If you've already programmed before, http://www.lua.org/pil/contents.html should help a lot.

0

https://scriptinghelpers.org/blog/how-to-teach-yourself-lua This is mainly for people with already some experience, but if you scroll down to near the end there's a bunch of useful links.

1 answer


--| WaitForChild |--

-- Waits for parent.child to exist, then returns it local function WaitForChild(parent, childName) assert(parent, "ERROR: WaitForChild: parent is nil") while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end


--| Variables |--

local GamePassService = game:GetService('GamePassService') local PlayersService = game:GetService('Players')

local VipDoor = script.Parent

local GamePassIdObject = WaitForChild(script, 'GamePassId')

local JustTouched = {}


--| Functions |--

-- Finds out which side the player is on and teleports them to the other local function TeleportToOtherSide(character, hitPart) local bottomOfDoor = VipDoor.CFrame.p - Vector3.new(0, VipDoor.Size.Y / 2, 0) local inFrontOfDoor = bottomOfDoor + VipDoor.CFrame.lookVector * 3 local behindDoor = bottomOfDoor - VipDoor.CFrame.lookVector * 3

local distanceToFront = (inFrontOfDoor - hitPart.Position).magnitude
local distanceToBack = (behindDoor - hitPart.Position).magnitude
if distanceToFront < distanceToBack then
    character:MoveTo(behindDoor)
else
    character:MoveTo(inFrontOfDoor)
end

end

-- When a player with the game pass touches the door, teleport them to the other side local function OnTouched(otherPart) if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then local player = PlayersService:GetPlayerFromCharacter(otherPart.Parent) if player and not JustTouched[player] then JustTouched[player] = time() if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then TeleportToOtherSide(player.Character, otherPart) end end end end

-- Removes old entries in JustTouched local function RemoveOldTouches() for player, touchTime in pairs(JustTouched) do if time() > touchTime + 0.3 then JustTouched[player] = nil end end end


--| Script Logic |--

VipDoor.Touched:connect(OnTouched)

while true do RemoveOldTouches() wait(1/30) end

3 comments

2

Tbh I'm wondering where you copy-pasted this from lol.

0

That's overdoing it; you could've just gave him viable sources via comments. e-e

0

xD

This discussion is preserved as it was. New answers, comments, and votes are closed.