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

Why won't local script print anything, not even "Hello World"?

Asked by 6 years ago
print("Hello World")
local player = game.Players.LocalPlayer
print(player.Name)

When I try to run that code, nothing is being displayed in the output from this local script. There is nothing interfering with the local script (Local script enabled) and the local script is in Workspace.

Is there any reason behind this?

3 answers

Log in to vote
2
Answered by
aazkao 787 Moderation Voter
6 years ago
Edited 6 years ago

LocalScript cannot run if its in workspace

From the roblox wiki:

A LocalScript will only run Lua code if it is a descendant of one of the following objects:

A Player’s Backpack, such as a child of a Tool

A Player’s Player/Character|character model

A Player’s PlayerGui

A Player’s PlayerScripts

The ReplicatedFirst service

Ad
Log in to vote
0
Answered by 6 years ago

Put the local script in StarterGui

Log in to vote
0
Answered by
piRadians 297 Moderation Voter
6 years ago

I would recommend placing it in StarterPlayerScripts

Answer this question