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

This doesn't work in game. Please help?

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)

5 comments

0

Is this a local script?

0

yes

0

If FilteringEnabled is enabled this script will not work since it is a LocalScript trying to edit global objects.

0

Where are global objects?

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.

1 answer

✓ Accepted answer

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

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