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

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

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

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. Tkdriverx 514 — 10y
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. Tkdriverx 514 — 10y
0
What part of it doesn't work? Tkdriverx 514 — 10y
0
Didn't work,...starting to think my game just has some type of virus ;l but thanks. kingalpha1 15 — 10y
View all comments (3 more)
0
Well..i don't knw kingalpha1 15 — 10y
0
You need to still wait for the character. Maybe change line 3 to just the Player.CharacterAdded:wait() Tkdriverx 514 — 10y
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 kingalpha1 15 — 10y

1 answer

Log in to vote
0
Answered by
Protall 10
10 years ago

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)

Ad

Answer this question