I am wondering how I can get my teleporters to only teleport a player only when they step off of the teleporter and step back onto it using debounce, instead of being teleported onto the other teleporter and then teleported right back.
01 | local assetID = 870836117 |
02 | local debounce = false |
03 | local pad = script.Parent.Parent.Parent.TeleB.Pad |
04 |
05 | local function OwnsShades(Hit) |
06 | if debounce = = false then |
07 | debounce = true |
08 |
09 | local plr = game.Players:GetPlayerFromCharacter(Hit.Parent) |
10 | if plr then |
11 | if game:GetService( "MarketplaceService" ):PlayerOwnsAsset(plr,assetID) then |
12 | print (plr.Name .. " owns the Midnight Shades" ) |
13 | Hit.Parent:MoveTo(pad.Position) |
14 | else |
15 | print (plr.Name .. " doesn't own the shades" ) |
something like this instead of debounce
script.Parent.Touched:connect(function(hit) if hit.Parent and not hit:FindFirstChild("RecentlyTeleported") then local teleportNotifier = Instance.new("StringValue") teleportNotifier.Name = "RecentlyTeleported" teleportNotifier.Parent = hit game.Debris:AddItem(teleportNotifier,2) -- however long you want to lock them out of teleportation
What I think you can use is the Disconnect method.
01 | local assetID = 870836117 |
02 |
03 | local pad = script.Parent.Parent.Parent.TeleB.Pad |
04 |
05 | local event |
06 | event = script.Parent.Touched:Connect( function (hit) |
07 |
08 |
09 |
10 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
11 | if plr then |
12 | if game:GetService( "MarketplaceService" ):PlayerOwnsAsset(plr,assetID) then |
13 | print (plr.Name .. " owns the Midnight Shades" ) |
14 | hit.Parent:MoveTo(pad.Position) |
15 | else |
You can learn more about it here: https://wiki.roblox.com/index.php?title=RBXScriptConnection#Disconnect
Hope this helps!