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)
According to the Official ROBLOX Wiki:
"In order for a LocalScript to function, it must be placed within one of three areas:
In a player's Backpack (can be indirectly, through a Tool or HopperBin)
In a player's character model
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.
You have to put the script in StarterGui for a LocalScript to work. Only Scripts run in workspace.