#Error Analysis
local p = script.Parrent
local v = game.Players:findFirstChild("PlayerName").ScreenGui.TeleportGui.TxtBox.Visible
Function onTouch(part)
V = true
end
p.Touched:connect(onTouch)
This script does not need a debounce. Debouncing is a concept in which only one set of executions can run per session. That way your executions doesn't look like it is glitching.
For example (a poor example at that), to turn on a computer, the process it takes to do so is about 20 seconds. If you click the power button once, it will start the process. If you click it again, the computer won't respond. And it will not respond until the 20 seconds is up.
But what you do need is to do some heavy debugging with this.
#Debugging
local p = script.Parent
local v = game.Players:FindFirstChild("PlayerName").PlayerGui.ScreenGui.TeleportGui.TxtBox
function onTouch(part)
v.Visible = true
end
p.Touched:connect(onTouch)
That looks better. Kind of.
The only problem you're going to run into is line 2; where the script tries to find WHICH player its referring to, in order to change the property you so desire.
So let's change one of your variables and your function.
function onTouch(part)
local HumanoidIsFound = part.Parent:FindFirstChild("Humanoid")
local PlayerIsFound = game.Players:GetPlayerFromCharacter(part.Parent)
if HumanoidIsFound and PlayerIsFound then
PlayerIsFound.PlayerGui.ScreenGui.TeleportGui.TxtBox.Visible = true
end
end
:FindFirstChild() & :GetPlayerFromCharacter() is awesome. These are what I like to call as verifiers (not a word; Chrome can verify). They verify whether the object you're looking for exists in the specified location.
:FindFirstChild() returns the object you're looking for, or nil.
:GetPlayerFromCharacter() returns the Player instance you're looking for from the character model you've given, or nil.
What line 6 (in the last code block) is saying is if...
...then the player's (that you're referring to) TxtBox will be visible!
Any questions/comments/skepticism? Check back with me. I'm here to help.
1 comment
sorry about any spelling or spacing problems obviously if you find any that would be a problem running the script. I spell check perfectly when typing the actual script