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

Why does this keep saying that Mouse is nil?

Asked by 10 years ago
p = script.Parent
player = game.Players:GetPlayerFromCharacter(p)
Mouse = player:GetMouse()
ls = p.Torso['Left Shoulder']
rs = p.Torso['Right Shoulder']
lh = p.Torso['Left Hip']
rh = p.Torso['Right Hip']
n = p.Torso['Neck']
la = p['Left Arm']
ra = p['Right Arm']
debsphere = false
debfire = false
Mouse.KeyDown:connect(function(Keyf)
    if Keyf == 'f' and not debsphere then
        debsphere = true
        p.Torso.Anchored = true
        ls.C0 = ls.C0 *CFrame.Angles(0,-.4,-1.5)
        rs.C0 = rs.C0 *CFrame.Angles(0,.4,1.5)
        sphere = Instance.new('Part', p)
        sphere.CanCollide = false
        sphere.Transparency = .5
        sphere.Shape = 'Ball'
        sphere.Anchored = true
        sphere.BrickColor = BrickColor.new('Really red')
        sphere.Size = Vector3.new(2,2,2)
        sphere.CFrame = p.Torso.CFrame *CFrame.new(0,0,-2)
        wait(.5)
        ls.C0 = ls.C0 *CFrame.Angles(-.42,.04,1.5)
        rs.C0 = rs.C0 *CFrame.Angles(-.42,-.04,-1.5)
        p.Torso.Anchored = false
        sphere.Touched:connect(function(hit) print(hit)
            hit = sphere:FindFirstChild('Humanoid')
            if hit~= nil then
                player:WaitForDataReady()
                hit.Health = Health -20
                demlvlexp = player:LoadNumber('demlvlexp')
                demlvlexp = demlvlexp +5
                player:SaveNumber('demlvlexp', demlvlexp)
                if hit.Health == 0 then
                    demlvlexp = player:LoadNumber('demlvlexp')
                    demlvlexp = demlvlexp +25
                    player:SaveNumber('demlvlexp', demlvlexp)
                end
            end
        end)
        function move()
            for moving = 1, 75 do
                wait(.01)
                sphere.CFrame = sphere.CFrame *CFrame.new(0,0,-.4)
            end
            for goaway = 1, 10 do
                wait(.01)
                sphere.Transparency = sphere.Transparency +(.05)
                sphere.CFrame = sphere.CFrame *CFrame.new(0,0,-.4)
            end
            sphere:remove()
        end
        move()
        wait(10)
        debsphere = false
    end
end)
Mouse.KeyDown:connect(function(Keyg)
    if Keyg == 'g' and not debfire then
        player:WaitForDataReady()
        if player:LoadNumber('demlvl') >= 7 then
        debfire = true
        p.Torso.Anchored = true
        ls.C0 = ls.C0 *CFrame.Angles(0,-.4,-1.5)
        rs.C0 = rs.C0 *CFrame.Angles(0,.4,1.5)
        fsphere = Instance.new('Part', p)
        fsphere.CanCollide = false
        fsphere.Transparency = .5
        fsphere.Shape = 'Ball'
        fsphere.Anchored = true
        fsphere.BrickColor = BrickColor.new('Really red')
        fsphere.Size = Vector3.new(2,2,2)
        fsphere.CFrame = p.Torso.CFrame *CFrame.new(0,0,-2)
        wait(.5)
        ls.C0 = ls.C0 *CFrame.Angles(-.42,.04,1.5)
        rs.C0 = rs.C0 *CFrame.Angles(-.42,-.04,-1.5)
        p.Torso.Anchored = false
        fsphere.Touched:connect(function(hit) print(hit)
            hit = fsphere:FindFirstChild('Humanoid')
            if hit~= nil then
                player:WaitForDataReady()
                hit.Health = Health -20
                demlvlexp = player:LoadNumber('demlvlexp')
                demlvlexp = demlvlexp +5
                player:SaveNumber('demlvlexp', demlvlexp)
                if hit.Health == 0 then
                    demlvlexp = player:LoadNumber('demlvlexp')
                    demlvlexp = demlvlexp +25
                    player:SaveNumber('demlvlexp', demlvlexp)
                end
            end
        end)
        function move()
            for moving = 1, 75 do
                wait(.01)
                fsphere.CFrame = fsphere.CFrame *CFrame.new(0,0,-.4)
            end
            for goaway = 1, 10 do
                wait(.01)
                fsphere.Transparency = fsphere.Transparency +(.05)
                fsphere.CFrame = fsphere.CFrame *CFrame.new(0,0,-.4)
            end
            fsphere:remove()
        end
        move()
        wait(10)
        debfire = false
        else
        end
    end
end)

that should work.. it works in studio but not in play

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Are you using a LocalScript? GetMouse only works from LocalScripts (unless you are in PlaySolo, which would explain your trouble)

0
0-o well that sucks... i am using it in a normal script so that i can save and load data as i want :/ User#600 0 — 10y
0
Unfortunately, you'll have to split them up. However, you can *easily* use a RemoteFunction to just do the save (easy as in almost no change here and really simple definition of the function) BlueTaslem 18071 — 10y
Ad

Answer this question