I have a portal that only allows access past a certain Stage.Value and it works fine... once. Prior to this I didn't have the debounce which caused the message to fire way too many times when someone under the required level tried to access it. With the debounce it works as intended for both the message and the initial teleport but if I come back to the portal in the same session it does nothing.
This error pops up in the console after/during the initial teleport so I presume it is disabling the script in some way?
attempt to index local 'plyr' (a nil value)
Or my code is just pure rubbish lol.
Any thoughts?
local place = CFrame.new(61.861, 310.247, 245.514) -- Where you want the player to go on touched
local debounce=true
script.Parent.Touched:Connect(function(part)
if debounce == true then
debounce = false
local parent = part.Parent
local plyr = game.Players:GetPlayerFromCharacter(parent)
if (plyr.leaderstats.Stage.Value < 25) then
local note = Instance.new("Message",game.Workspace)
note.Text = "Requires Stage 25 to access"
wait(2)
note:Remove()
debounce = true
elseif (plyr.leaderstats.Stage.Value >= 25) then
local plyrmod = plyr.Character.HumanoidRootPart
plyrmod.CFrame = place
debounce = true
end
end
end)

3 comments
That's something I really need to get used to doing! Thanks for explaining it in such user friendly terms :)
Would this explain why it would only fire once and then fail thereafter?
Finally had time to test this... and success, thank you so much!!