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

Why doesnt this work in Workspace?

Asked by 9 years ago
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)

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 jerek123 0 — 9y

3 answers

Log in to vote
2
Answered by
duckwit 1404 Moderation Voter
9 years ago

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().

Ad
Log in to vote
1
Answered by
Muoshuu 580 Moderation Voter
9 years ago

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

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. duckwit 1404 — 9y
0
Although it still works in all of the listed locations Muoshuu 580 — 9y
Log in to vote
0
Answered by 9 years ago

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

0
A LocalScript runs in PlayerGui, Backpack, and the Player's Character model. duckwit 1404 — 9y
0
I know, but why downvote me? I stated a fact. DominusAstra -2 — 9y

Answer this question