Why isn't it even printing at the first line of code?

ok. so i’ve been working on following a tutorial for a voting system, and then i ran into a bug that i think might even be with roblox itself!

because it won’t print even the first line of code, and yet all it is defining variables, very confused and in need of help.

this is the piece of code:

print("attempting to define variables")
local player = game.Players.LocalPlayer
local voted = player:WaitForChild("voted")
local rep = game:GetService("ReplicatedStorage")
local votere = rep:WaitForChild("RemoteEvent"):WaitForChild("Vote")
local variables = rep:WaitForChild("Variables")
local boolean = rep:WaitForChild("Booleans"):WaitForChild("RevealVotes")
local choice = variables:WaitForChild("Choice1")
local votechoice = variables:WaitForChild("VoteChoice1")
local votescounter = script.Parent.Screen.SurfaceGui.Votes
print("variables defined")

it’s under a model that’s under a model in workspace, and it’s a local script, thanks for reading and please help!

[ for context it won’t print even in console:
" attempting to define variables "
which is really annoying. ]

Your script is either disabled, or not a descendant of the following:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts .
  • The ReplicatedFirst service

(LocalScript | Roblox Creator Documentation)

1 Like

Local scripts don’t work in workspace…

1 Like

They do, however, they can only run if they are a descendant of the following objects:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts.

Anything else won’t.

1 Like

:smile: I was in a rush to type that, but yes you’re right, local scripts only work if their parents are as you’ve stated.

bullettrain5 if you want your local script to work I rather you read above.
If you want to sum it:
Local script only works in

  • Players backpack
  • Player itself (the players model in workspace)
  • StarterGui/PlayerGui
  • StarterCharacterScript
  • StarterPlayerScript

There might be some places I missed but those that Xacima and I have stated is where a local script will work.

1 Like