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

This doesn't work in game. Please help?

Asked by 8 years ago

So, when I test it in studio, it works fine, but in-game it doesn't work. The server is a personal server if you wonder what type of place it is.

Player = game.Players.LocalPlayer
Character = Player.Character
Torso = Character.Torso
Mouse = Player:GetMouse()
hold = false


Mouse.Button1Down:connect(function()  
    if hold == false then
       hold = true
        while hold == true do
           wait(0.00001)
            Player.Character.Humanoid.WalkSpeed = Player.Character.Humanoid.WalkSpeed +1
                wait(0.1)
                local Brick = Instance.new("Part", Character) --Changed Player to Character                Brick.Anchored = true
                Brick.Position = Torso.Position + Vector3.new(5,0, 0)
                Brick.BrickColor = BrickColor.new("New Yeller")
                Brick.Size = Vector3.new(3,5,4)  
                Brick.Anchored = true
                Brick.Transparency = 0.5
                Brick.Reflectance = 0.4
                game.Debris:AddItem(Brick,1)
                Brick.TopSurface = 0
                Brick.BottomSurface = 0
                Brick.CanCollide = false
                local smoke = Instance.new("Smoke", Brick)
                smoke.Opacity = 0.3
                smoke.RiseVelocity = 0.4
                smoke.Size = 0.5
                smoke.Color = Color3.new(226,226,36)
                smoke.Enabled = true
                local fire = Instance.new("Fire", Brick)
                fire.Enabled = true
                fire.Heat = 10
                fire.Color = Color3.new(255,173,0)
                fire.SecondaryColor = Color3.new(255,0,0)
                fire.Size = 15

        end

    end





end)
Mouse.Button1Up:connect(function()
    if hold == true then
        hold = false
        Player.Character.Humanoid.WalkSpeed = 16
    end

end)

0
Is this a local script? Perci1 4988 — 8y
0
yes tyler46783 0 — 8y
0
If FilteringEnabled is enabled this script will not work since it is a LocalScript trying to edit global objects. FearMeIAmLag 1161 — 8y
0
Where are global objects? tyler46783 0 — 8y
0
Global objects being objects in the workspace or other server-restricted locations that every player can see such as characters in your case. FilteringEnabled can be toggled in the properties list of the Workspace. FearMeIAmLag 1161 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I Had This Issue As Well My Friend...

You need to insert a WaitForChild line at the variables. For example, you have

Torso = Character.Torso

So now, you need to insert WaitForChild in the script like this!

Torso = Character:WaitForChild("Torso")

You can also insert it here!

Character = Player:WaitForChild("Character")

So next time you run into a issue, use WaitForChild

GreekGodOfMLG

Ad

Answer this question