Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this keep saying that Mouse is nil?

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

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

2 comments

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 :/

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.