Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script works in studio but not when I play the game on Roblox.com. Why?

Asked by 6 years ago

So I have a script that brings up text boxes with dialog (someone on this site helped to make it work). When I tested in ROBLOX studio, it worked perfectly, but when I play the game on https://web.roblox.com/games, it doesn't work. Here's the script...

repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character

local player = game.Players.LocalPlayer

local pgui = player:WaitForChild('PlayerGui')

local sgui = pgui:WaitForChild('ScreenGui')



local text1 = sgui:WaitForChild('text1')

local text2 = sgui:WaitForChild('text2')

local text3 = sgui:WaitForChild('text3')

local text4 = sgui:WaitForChild('text4')

local text5 = sgui:WaitForChild('text5')

local text6 = sgui:WaitForChild('text6')

local text7 = sgui:WaitForChild('text7')

local text8 = sgui:WaitForChild('text8')



text1.Visible = true

wait(3)

text1.Visible = false

wait(2)

text2.Visible = true

wait(3)

text2.Visible = false

wait(2)

text3.Visible = true

wait(3)

text3.Visible = false

wait(2)

text4.Visible = true

wait(3)

text4.Visible = false

wait(2)

text5.Visible = true

wait(3)

text5.Visible = false

wait(2)

text6.Visible = true

wait(2)

text6.Visible = true

wait(3)

text6.Visible = false

wait(2)

text7.Visible = true

wait(3)

text7.Visible = false

wait(2)

text8.Visible = true

wait(3)

text8.Visible = false

Sorry it's so long, but do you have any suggestions on why it won't work on the actual site?

0
Filtering enabled on or off? And Script or Local Script oftenz 367 — 6y
0
Normal script, and filtering enabled is whatever the default is because I did not change it. happygirl29922 -3 — 6y
0
Make it a local script. oftenz 367 — 6y
0
yes, im pretty sure you can only use "game.Player.LocalPlayer" in a local script only cruizer_snowman 117 — 6y

1 answer

Log in to vote
0
Answered by
Async_io 908 Moderation Voter
6 years ago
Edited 6 years ago

From seeing the comments, this is a Script. It's important to keep in mind that you shouldn't really Studio Test as it's not the best method of testing. I use it just to find and basic typos I have. To really efficiently test, see this link. This will simulate an actual Roblox Game. It will even make it easier to see the server output.

Now with a script, they're not able to get the LocalPlayer. Scripts are mostly server-side, whereas Local Scripts are mostly client-based.

An easy analogy would be you have a neighborhood (server). Each house (client) has one person. If you say "Find the person in your house" to the neighborhood, they're going to have no clue who to find. If you said "Find the person in your house" to a client, they'll pinpoint it exactly. It's also important to note that a Server Script isn't really what you're looking for to change a GUI. Local Scripts are usually the GUI-changers.

When scripting, it's important to know the differences between scripts and what they can do. A local script, for example, is mostly aimed towards the player themselves. A Script (server script) would really be for all players or for world changes. Last is a module script, which I most recently learned about. They're basically functions that you can call in both scripts. They're pretty neat and I love using them.

When you start to learn about FilteringEnabled, you'll really have to use different scripts and understand what they can and can't do. It's not that hard to understand and it can really even be a fun challenge. (It's important to note that most games nowadays are FilteringEnabled, which prevents most hackers from doing they're little hacking stuffs.)

I would definitely study up on FilteringEnabled when you have the chance.

If my answer helped, please click Accept Answer!

0
Fun Fact: You can push F9 in a Roblox Game to see the developer console. (Basically the in-game script output.) Async_io 908 — 6y
Ad

Answer this question