Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesnt this work in Workspace?

player = game.Players.LocalPlayer
mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
		key = key:lower()
	if key == "q" then
for i = 0,0.5,.1 do
	wait()
RightShoulder = game.Workspace.Player.Torso["Right Shoulder"]
RightShoulder.C0 = RightShoulder.C0 * CFrame.fromEulerAnglesXYZ(0,-i,0)
end
for q = 0,0.5,.1 do
	wait()
RightShoulder.C0 = RightShoulder.C0 * CFrame.fromEulerAnglesXYZ(q,0,0)
end
wait()
for i = 0,0.5,.1 do
	RightShoulder.C0 = RightShoulder.C0 * CFrame.fromEulerAnglesXYZ(-i,0,0)
		wait()
end
for i = 0,0.5,.1 do
	RightShoulder.C0 = RightShoulder.C0 * CFrame.fromEulerAnglesXYZ(0,i,0)
		wait()
end
		for i = 3,45 do
			wait()
			earth = Instance.new("Part",workspace)
			earth.Size = Vector3.new(4,4,4)
			earth.CanCollide = false
			earth.BrickColor = BrickColor.new("Reddish brown")
			earth.Anchored = true
			earth.CFrame = player.Character.Torso.CFrame * CFrame.new(0,0,-5+-i) * CFrame.fromEulerAnglesXYZ(math.random(),math.random(),math.random())
			player.Character.Torso.Anchored = true
			my = game.Lighting.Earth:Clone()
			my.Parent = earth
		end
		player.Character.Torso.Anchored = false
end
end)

1 comment

0

You may see i've gotten a lil bit better, this one doesnt work but all the other spells work. they're are all in seperate scripts and local

3 answers

According to the Official ROBLOX Wiki:

"In order for a LocalScript to function, it must be placed within one of three areas:

  1. In a player's Backpack (can be indirectly, through a Tool or HopperBin)

  2. In a player's character model

  3. In a player's PlayerGui "

So, by definition, a LocalScript will not run in the Workspace.

If you put that same code into a regular Script Instance, though, it still wouldn't work because it tries to make use of some client-only services, such as LocalPlayer and GetMouse().

LocalScript only work in the Character, Camera, and Player. Placing one in the workspace virtually disables it.

2 comments

0

The ROBLOX Wiki doesn't say that it'll run in the Camera, or the Player. It has to be in the PlayerGui, Character model, or Backpack.

0

Although it still works in all of the listed locations

You have to put the script in StarterGui for a LocalScript to work. Only Scripts run in workspace.

2 comments

0

A LocalScript runs in PlayerGui, Backpack, and the Player's Character model.

0

I know, but why downvote me? I stated a fact.

This discussion is preserved as it was. New answers, comments, and votes are closed.