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

Fireball script, works only in studio, not in game. Help Please?

Asked by
Rikuzao 20
9 years ago

Hey, i have edited Friaza's fireball script witch only works in Studio, not in-game. Anyways, here's the script:

Player = script.Parent.Parent -- Gets LocalPlayer 
Character = Player.Character -- Gets Players Character 
Mouse = Player:GetMouse() -- Gets players Mouse 
function onKeyDown(key) 
    key = key:lower() 
    if key == "z" then 
        x = Instance.new("Part") 
        x.TopSurface = "Smooth" 
        x.BottomSurface = "Smooth" 
        x.Shape = "Ball" 
        x.Transparency = .7
        x.BrickColor = BrickColor.new("Bright red") 
        f = Instance.new("Fire") 
        f.Parent = x 
        f.Size = 12 
        f.Heat = 0 
        y = Instance.new("BodyVelocity") 
        y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        y.velocity = Character.Torso.CFrame.lookVector*80
        y.Parent = x  
        x.Parent = Workspace 
        x.CFrame = Character.Torso.CFrame*CFrame.new(0, 0, -12)

    end 
end 
Mouse.KeyDown:connect(onKeyDown)

Please help!

2 answers

Log in to vote
2
Answered by 9 years ago

On the first line, instead of putting,

Player = script.Parent.Parent

put this:

Player = game.Players.LocalPlayer
0
It does not work since the first thing i did after putting it into workspace was putting it into starerpack Rikuzao 20 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

The difference between PlaySolo and In game is that In game, the character loads a little after the Player loads. In Playsolo, the character and Player load immediately. To fix this, we wait for the Character to load using repeat wait() until Player.Character

Player = script.Parent.Parent -- Gets LocalPlayer 
repeat wait() until Player.Character
Character = Player.Character -- Gets Players Character 
Mouse = Player:GetMouse() -- Gets players Mouse 
function onKeyDown(key) 
    key = key:lower() 
    if key == "z" then 
        x = Instance.new("Part") 
        x.TopSurface = "Smooth" 
        x.BottomSurface = "Smooth" 
        x.Shape = "Ball" 
        x.Transparency = .7
        x.BrickColor = BrickColor.new("Bright red") 
        f = Instance.new("Fire") 
        f.Parent = x 
        f.Size = 12 
        f.Heat = 0 
        y = Instance.new("BodyVelocity") 
        y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        y.velocity = Character.Torso.CFrame.lookVector*80
        y.Parent = x  
        x.Parent = Workspace 
        x.CFrame = Character.Torso.CFrame*CFrame.new(0, 0, -12)

    end 
end 
Mouse.KeyDown:connect(onKeyDown)

Answer this question