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

Script works in studio, but when i enter game it's doesn't work. In DevConsole "c it's nil value". ?

Asked by 6 years ago
Edited 6 years ago

Help! this is work in studio, but not in game, it's says "c it's nil value"

player = game.Players.LocalPlayer mouse = player:GetMouse() c = player.Character anima = script:WaitForChild("Smash") Enabled = true mouse.KeyDown:connect(function(key)

key = key:lower()

if key == "z" then

    if not Enabled then return end

    Enabled = false

    local AnimaStart = c.Humanoid:LoadAnimation(anima)

    AnimaStart:Play()

    c.Humanoid.Health = c.Humanoid.Health -15

    local q = Instance.new("Part", c)

    q.Shape = "Block"

           q.Anchored = true

    q.CanCollide = false

    q.BottomSurface = "Smooth"

    q.TopSurface = "Smooth"

    q.Material = "Metal"

    q.Transparency = 0.3

    q.BrickColor = BrickColor.new("Ghost grey")

    q.Size = Vector3.new(5,5,25)

    q.CFrame = c.Torso.CFrame *CFrame.new(1.3,0,-15)

    local u = Instance.new("SpecialMesh")

    u.MeshType = "Sphere"

    u.Parent = q

    for i = 1, 20 do

        q.Size = q.Size +Vector3.new(1,1,1)
        wait()

        q.Transparency = q.Transparency +0.1

        q.Size = q.Size +Vector3.new(1,1,1)
        wait()

        q.Transparency = q.Transparency +0.1

        q.Size = q.Size +Vector3.new(1,1,1)
        wait()

        q.Transparency = q.Transparency +0.1

        q.Size = q.Size +Vector3.new(0,0,0.1)
        wait()

    end

    wait(5)

    q:Destroy()

    Enabled = true

end

end)

1 answer

Log in to vote
0
Answered by
iborek 15
6 years ago
Edited 6 years ago

Are you using LocalScript or Script? If Script, So it should be in LocalScript.

LocalPlayer and GetMouse is client side only.

Edit:

Try this.

repeat wait() until game.Players.LocalPlayer
repeat wait() until game.Players.LocalPlayer.Character  
player = game.Players.LocalPlayer 
mouse = player:GetMouse() 
c = player.Character 
anima = script:WaitForChild("Smash") 
Enabled = true 

mouse.KeyDown:connect(function(key)
    key = key:lower()
    if key == "z" then
        if not Enabled then return end
        Enabled = false
        local AnimaStart = c.Humanoid:LoadAnimation(anima)
        AnimaStart:Play()
        c.Humanoid.Health = c.Humanoid.Health -15
        local q = Instance.new("Part", c)
        q.Shape = "Block"
        q.Anchored = true
        q.CanCollide = false
        q.BottomSurface = "Smooth"
        q.TopSurface = "Smooth"
        q.Material = "Metal"
        q.Transparency = 0.3
        q.BrickColor = BrickColor.new("Ghost grey")
        q.Size = Vector3.new(5,5,25)
        q.CFrame = c.Torso.CFrame *CFrame.new(1.3,0,-15)
        local u = Instance.new("SpecialMesh")
        u.MeshType = "Sphere"
        u.Parent = q

        for i = 1, 20 do
            q.Size = q.Size +Vector3.new(1,1,1)
            wait()
            q.Transparency = q.Transparency +0.1
            q.Size = q.Size +Vector3.new(1,1,1)
            wait()
            q.Transparency = q.Transparency +0.1
            q.Size = q.Size +Vector3.new(1,1,1)
            wait()
            q.Transparency = q.Transparency +0.1
            q.Size = q.Size +Vector3.new(0,0,0.1)
            wait()
        end
    wait(5)
    q:Destroy()
    Enabled = true
    end
end)
0
i did it on LocalScript ofc. 666U5erName666 2 — 6y
0
I've added a code here. Try it. iborek 15 — 6y
0
thank you so much! it's worked! sorry for late, i was busy a little bit 666U5erName666 2 — 6y
Ad

Answer this question