|
| 22 Apr 2014 04:07 PM |
The following script is placed in a brick that the player walks through, which should trigger the script, but it isn't working. I've got no errors, so I'm thinking it has something to do with the actual TextLabel, but I'm not exactly sure what.
The script is supposed to display the string (local myString) one letter at a time, and then remove the text after a few seconds.
buttonDebounce = false
function onTouched(hit) if not buttonDebounce then return end buttonDebounce = true -- enable debounce local player = game.Players:GetPlayerFromCharacter(hit.Parent) if not player then return end gui = StarterGUI.ScreenGui.Text1
local myString = "And thus Justin begins on his journey, aimlessly wandering through hallway after hallway, trying to find his fellow employees." for i = 1, #myString do gui.Text = gui.Text..myString:sub(1,i) wait(.5) end
wait(5) -- wait 5 seconds gui.Text = "" -- Delete text buttonDebounce = false -- disable debounce end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
redlo43
|
  |
| Joined: 16 Feb 2011 |
| Total Posts: 4722 |
|
|
| 22 Apr 2014 04:11 PM |
| because buttonDebounce = false, it will never get past your conditional statement |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 04:13 PM |
And if it helps, here are a few properties of the TextLabel...
Active = false BackgroundTransparency = 1 BorderSizePixel = 0 ClassName = TextLabel Name = Text1 Parent = ScreenGUI -- and ScreenGUI's parent is StarterGUI Position = {0, 0}, {0, -300} Rotation = 0 Size = {1, 0}, {0.800000012, 0} SizeConstraint = RelativeXY Visible = true ZIndex = 1 Archivable = true ClipsDescendants = false Draggable = false Text = "" Font = Legacy FontSize = Size24 TextBounds = 0,36 TextFits = true TextScaled = false TextStrokeTransparency = 1 TextTransparency = 0 TextWrapped = true TextXAlignment = Center TextYAlignment = Center |
|
|
| Report Abuse |
|
|
redlo43
|
  |
| Joined: 16 Feb 2011 |
| Total Posts: 4722 |
|
|
| 22 Apr 2014 04:17 PM |
| I already told you that there is a problem with your debounce |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 04:29 PM |
| @Red; I know, my reply was late. Chill haha |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 04:55 PM |
Alright I'm still confused. I read up on 'not' and 'debounce' on the wiki, but I'm still not exactly sure what they mean.
In an attempt to fix, I set debounce to true, though I'm not entirely sure what that means exactly.
Here is the script now and a few comments/questions I have:
buttonDebounce = true -- Not entirely sure what this does
function onTouched(hit) if not buttonDebounce then return end -- This line confuses me the most; I think it means that if buttonDebounce is false, then the script ends? buttonDebounce = true -- enable debounce local player = game.Players:GetPlayerFromCharacter(hit.Parent) if not player then return end -- So this basically checks if there is a player or not, and if there isn't, then the script ends? gui = StarterGUI.ScreenGui.Text1
local myString = "And thus Justin begins on his journey, aimlessly wandering through hallway after hallway, trying to find his fellow employees." for i = 1, #myString do gui.Text = gui.Text..myString:sub(1,i) wait(.5) end
wait(5) -- wait 5 seconds gui.Text = "" -- Delete text buttonDebounce = false -- disable debounce end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 22 Apr 2014 05:24 PM |
Here ya go
buttonDebounce = false
function onTouched(hit) if buttonDebounce == false then buttonDebounce = true -- enable debounce local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then gui = StarterGUI.ScreenGui.Text1
local myString = "And thus Justin begins on his journey, aimlessly wandering through hallway after hallway, trying to find his fellow employees." for i = 1, #myString do gui.Text = gui.Text..myString:sub(1,i) -- this would make it aanandandtandth, if you wanna fix it, make it I,I or remove gui.Text.. wait(.5) end
wait(5) -- wait 5 seconds gui.Text = "" -- Delete text buttonDebounce = false -- disable debounce end end
script.Parent.Touched:connect(onTouched)
The if's may be easier for you to understand now... |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 05:27 PM |
| It does make it a lot clearer. Thanks! I'll let you know if anything doesn't work. |
|
|
| Report Abuse |
|
|
| |
|
|
| 22 Apr 2014 05:29 PM |
| Hm...It still doesn't work. Do I need to copy and paste the text from the string into the Text property of the TextLabel? |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 05:32 PM |
You did what my comment said?
I am not sure. Sorry. Maybe others can help now?
Do you get an error now? |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 05:34 PM |
| Oh wait, I forgot to check that. Turns out it's missing an 'end'. Gonna re-test. |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 05:41 PM |
Re-tested. There were no new errors and it still doesn't work. Does the Text in TextLabel have to match the text in the string specified in the script?
Also, the one line that still confuses me is highlighted:
buttonDebounce = false
function onTouched(hit) if buttonDebounce == false then buttonDebounce = true -- enable debounce local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then gui = StarterGUI.ScreenGui.Text1
local myString = "And thus Justin begins on his journey, aimlessly wandering through hallway after hallway, trying to find his fellow employees." for i = 1, #myString do gui.Text = gui.Text..myString:sub(i,i) -- What does this line do/say? wait(.5) end
wait(8) -- wait 5 seconds gui.Text = "" -- Delete text buttonDebounce = false -- disable debounce end end end |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 05:48 PM |
local buttonDebounce = false --forgot local
function onTouched(hit) if buttonDebounce == false then buttonDebounce = true -- enable debounce local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then gui = StarterGUI.ScreenGui.Text1
local myString = "And thus Justin begins on his journey, aimlessly wandering through hallway after hallway, trying to find his fellow employees." for i = 1, #myString do gui.Text = gui.Text..myString:sub(i,i) -- What does this line do/say? wait(.5) end
wait(8) -- wait 5 seconds gui.Text = "" -- Delete text buttonDebounce = false -- disable debounce end end end |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 05:52 PM |
Still doesn't work :\
Does the Text in the TextLabel it's linking to (Text1) need to contain the same text as in string myString in the script?
|
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 06:04 PM |
Change that line to
gui.Text = gui.Text .. mystring:sub(i, i) |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 06:09 PM |
| But isn't the 'S' capitalized in the previous lines |
|
|
| Report Abuse |
|
|
| |
|
|
| 22 Apr 2014 06:21 PM |
Well I did change one thing. Instead of ScreenGUI, I changed it to ScreenGui.
But it still doesn't work. No errors.
Any ideas?
(Btw, I still have a feeling I didn't set up the TextLabel itself correctly. |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 06:26 PM |
Found it! I think...
Change
gui = StarterGUI.ScreenGui.Text1
to
gui = player.PlayerGui.ScreenGui.Text1 |
|
|
| Report Abuse |
|
|
| |
|
|
| 22 Apr 2014 06:37 PM |
Here's the script again if needed (There were some changes made back and forth between the posts, not sure if any new problems were caused in doing so)
buttonDebounce = false
function onTouched(hit) if buttonDebounce == false then buttonDebounce = true -- enable debounce local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then gui = player.PlayerGui.ScreenGui.Text1
local myString = "And thus Justin begins on his journey, aimlessly wandering through hallway after hallway, trying to find his fellow employees." for i = 1, #myString do gui.Text = gui.Text..myString.sub(i,i) wait(.1) end
wait(8) -- wait 5 seconds gui.Text = "" -- Delete text buttonDebounce = false -- disable debounce end end end |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2014 06:41 PM |
| I'll fix dis maine just wait >:I |
|
|
| Report Abuse |
|
|