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

Why Won't This Code Work Online?

Asked by
StoIid 364 Moderation Voter
8 years ago

This works in Studio, but not when I try it in an actual game and I have no idea why.

bin = script.Parent
Me = script.Parent.Parent.Parent
me = Me
name = "Sky Dragon's Drive"
Backpack = bin.Parent
Player1 = Backpack.Parent
Player = Player1.Character
Hum = Player.Humanoid
Run = game:GetService("RunService")
color = BrickColor.new("Black")
COOLDOWN = 10

function onButton1Down(mouse)


enabled = true
        MagicSym = Instance.new("Part")
        MagicSym.Parent = me.Character
        MagicSym.Anchored = true
        MagicSym.CanCollide = false
        MagicSym.formFactor = "Symmetric"
        MagicSym.BrickColor = BrickColor.new(0)
        MagicSym.Transparency = 1
        MagicSym.Name = "MagicSym"
        MagicSym.Size = Vector3.new(12,.5,12)
        MagicSym.TopSurface = "Smooth"
        MagicSym.BottomSurface = "Smooth"
        MagicSym.CFrame = me.Character.Torso.CFrame*CFrame.new(0, -3.1, 0 )
        d = Instance.new("Decal")
        d.Name = "Circle"
        d.Parent = MagicSym
        d.Face = "Top"
        d.Texture = ""
        p = Instance.new("Decal")
        p.Name = "Circle"
        p.Parent = MagicSym
        p.Face = "Bottom"
        p.Texture = d.Texture
        game.Debris:AddItem(MagicSym,2)

    d = Instance.new("StringValue",me.Backpack)
d.Name = "Drive"
print("Derp")
x = Instance.new("Part", Player)
x.Size = Vector3.new(4,4,4)
x.Shape = "Ball"
x.BrickColor = color
x.Transparency = 0.9
x.Position = Player.Torso.Position
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
x.CanCollide = false
x.Anchored = false
z = Instance.new("SpecialMesh")
z.MeshType = "FileMesh"
z.MeshId = "http://www.roblox.com/asset/?id=12212520"
z.Scale = Vector3.new(0,0,0)
z.Parent = x
local emitter = script.ParticleEmitter:Clone()
emitter.Parent = x
w1 = Instance.new("Weld", Player)
w1.Part0 = Player["Torso"]
w1.Part1 = x
w1.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) *CFrame.new(0,-1.5, 0)
fd = script.Firedamage:clone()
fd.Parent = x
p = script.PointLight:clone()
p.Parent = x
p.Brightness = 0
o = Instance.new("StringValue",x)
        o.Value = me.Name
        o.Name = "Owner"



ws = Hum.WalkSpeed + 1

wait(0.25)
for Charging = 1, 50 do
                z.Scale = z.Scale + Vector3.new(0.1,.3,.1)
                p.Brightness = p.Brightness + .1
                Run.Stepped:wait(0.05)
end
fd.Disabled = false
Hum.WalkSpeed = 80
Hum.MaxHealth = 150
Hum.Health = (Hum.Health) + (30)
for i = 1,60 do
    z.Scale = z.Scale + Vector3.new(.1,.3,.1)
    p.Range = p.Range + 1
    p.Brightness = p.Brightness + 1
    x.Transparency = x.Transparency - .05
    wait(.25)
    z.Scale = z.Scale - Vector3.new(.1,.3,.1)
    p.Range = p.Range - 1
    x.Transparency = x.Transparency + .05
    p.Brightness = p.Brightness - 1
    wait(.25)
end
for ChargedEnd = 1, 50 do
                z.Scale = z.Scale - Vector3.new(.1,.3,.1)
                p.Brightness = p.Brightness - .1
                x.Transparency = x.Transparency + .2

                Run.Stepped:wait(0.02)
end

d:remove()
Hum.WalkSpeed = ws
Hum.MaxHealth = 100

x:remove()


wait(COOLDOWN)


enabled = true

end




enabled = true
function onS(mouse) 
mouse.Button1Down:connect(function() onButton1Down(mouse) end) 
end 
bin.Selected:connect(onS)

2 answers

Log in to vote
0
Answered by 8 years ago

Here this should help it helped me with this same problem

https://scriptinghelpers.org/blog/it-works-in-studio-but-not-online

Ad
Log in to vote
0
Answered by 8 years ago

Is this a SB script? If it is, let me fix this for you.

bin = script.Parent
Me = game.Players.LocalPlayer -- I changed it to LocalPlayer instead of your regular one.
me = Me

If that does not work, I don't know the problem.

0
SB? Also it didn't work. The output prints an error saying there is something wrong with Line 8 (In the online game). It still works fine in the Studio but not Online. It says that "Player" is a nil value. Think you can fix? StoIid 364 — 8y

Answer this question