Scripting Helpers is winding down operations and is now read-only. More info→
Log in to vote

my game pass teleport server script is not working help?

Asked by 1 year ago
Edited 1 year ago

--| 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 DebrisService = Game:GetService('Debris')

local Teleporter = script.Parent

local GamePassIdObject = WaitForChild(script, 'GamePassId') local ExitPartObject = WaitForChild(script, 'ExitPart')

local JustTouched = {}

--| Functions |--

-- 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 local character = player.Character if not character:FindFirstChild('JustTeleported') then local justTeleported ='StringValue') justTeleported.Name = 'JustTeleported' DebrisService:AddItem(justTeleported, 0.3) justTeleported.Parent = character character:MoveTo(ExitPartObject.Value.Position) end 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 |--


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

Would you be able to put ur code in a code block. it would be easier to read. theking66hayday 841 — 1y
any specific error? irid_leas 97 — 1y
game pass does not work LYESPILLEDINMYEYES -14 — 1y
Edit the question and put 5 spaces before each row. Gigaset39 111 — 1y

Answer this question