generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Can't Get This to Work...

Previous Thread :: Next Thread 
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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 is not online. 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
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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 is not online. 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
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
22 Apr 2014 04:29 PM
@Red; I know, my reply was late. Chill haha
Report Abuse
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
22 Apr 2014 05:04 PM
B1
Report Abuse
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
22 Apr 2014 05:16 PM
B2
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
22 Apr 2014 05:29 PM
No problem
Report Abuse
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
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
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
22 Apr 2014 06:04 PM
Change that line to

gui.Text = gui.Text .. mystring:sub(i, i)
Report Abuse
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
22 Apr 2014 06:09 PM
But isn't the 'S' capitalized in the previous lines
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
22 Apr 2014 06:11 PM
Oh yeah.. Sorry
Report Abuse
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
22 Apr 2014 06:26 PM
Found it! I think...

Change

gui = StarterGUI.ScreenGui.Text1

to

gui = player.PlayerGui.ScreenGui.Text1
Report Abuse
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
22 Apr 2014 06:35 PM
Nope :\

Whyyyyy
Report Abuse
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
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
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
22 Apr 2014 06:41 PM
I'll fix dis maine just wait >:I
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image