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

How come my local script doesn't work outside build mode?

local enabled = true
Player = script.Parent.Parent
character = Player.CharacterAdded:wait();
mouse = Player:GetMouse()
run = game:GetService("RunService")
Torso = Player.Character.Torso

function onKeyDown(key)
	key = key:lower()
	if key == "e" then
		f = Instance.new("Fire")
		f.Color = Color3.new(0, 85, 255)
		f.SecondaryColor = Color3.new(0, 170, 255)
		f.Size = 15
		f.Heat = 25
		f.Parent = Torso
		y = Instance.new("BodyVelocity")
		y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
		y.velocity = Player.Character.Torso.CFrame.lookVector*80
		y.Parent = Torso
		game.Debris:AddItem(f,4)
		game.Debris:AddItem(y,2)
	end
end

mouse.KeyDown:connect(onKeyDown)

two questions in the same hour....a new kind of low u.u

7 comments

0

CharacterAdded:wait() doesn't return a character. Just remove line 3 altogether. The arguments for Color3 are numbers between 0 and 1, so to get the correct number, use your number (for example 85) and do 85/255 to get the correct number.

0

LocalScripts (when Workspace.FilteringEnabled is set to true) can't change things in the server side. But it will work client side. Try setting Player to game.Players.LocalPlayer instead.

0

What part of it doesn't work?

0

Didn't work,...starting to think my game just has some type of virus ;l but thanks.

0

Well..i don't knw

0

You need to still wait for the character. Maybe change line 3 to just the Player.CharacterAdded:wait()

0

Nope,i'm now 100% sure it's my game...might be viruses...thanks though..none of my scripts work outside of build mode

1 answer

✓ Accepted answer

I can't give much more advice than what people have told you but I fixed it up for you

local enabled = true
Player = game.Players.LocalPlayer
while not Player.Character do wait(.03) end
character = Player.Character
mouse = Player:GetMouse()
run = game:GetService("RunService")
Torso = Player.Character:WaitForChild("Torso")

function onKeyDown(key)
    key = key:lower()
    if key == "e" then
        local f = Instance.new("Fire")
        f.Color = Color3.new(0, 85, 255)
        f.SecondaryColor = Color3.new(0, 170, 255)
        f.Size = 15
        f.Heat = 25
        f.Parent = Torso
        local y = Instance.new("BodyVelocity")
        y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        y.velocity = Player.Character.Torso.CFrame.lookVector*80
        y.Parent = Torso
        game.Debris:AddItem(f,4)
        game.Debris:AddItem(y,2)
    end
end

mouse.KeyDown:connect(onKeyDown)

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