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

Mouse Hover Enter Script Not Functioning?

When your mouse hovers over this part, it functions nude, then checks to see if this bool value is true or false. If it is true it closes the door and disables the script, if it isn't true it just disables the script. I have many identical scripts within my game however, this one doesn't seem to function after the nude function...


function nude()
	kk = game.Workspace.Hello1:GetChildren()
		kkk = game.Workspace.Hello1.D1:GetChildren()
		for i,v in pairs(kk) do
			if v.ClassName == "Part" then
				v.Transparency = 0
				v.CanCollide = true
		end
		end
			for i,v in pairs(kkk) do
				if v.ClassName == "Part" then
					v.Transparency = 0
					v.CanCollide = true
				end
			end
		
			jj = game.Workspace.Hello2:GetChildren()
			jjj = game.Workspace.Hello2.D1:GetChildren()
			for i,v in pairs (jj) do
				if v.ClassName == "Part" then
					v.Transparency = 0
					v.CanCollide = true
			end
			end
				for i,v in pairs(jjj) do
					if v.ClassName == "Part" then
						v.Transparency = 0
						v.CanCollide = true
		end
	end
end


Ready = true

script.Parent.ClickDetector.MouseHoverEnter:Connect(function()
		Ready = false
		nude()
		
		if game.Workspace.CloseMe.D1.Opened.Value == true then
			game.Workspace.CloseMe.D1.Part0.DesiredAngle = 0
			game.Workspace.CloseMe.D1.Opened.Value = false
			game.Workspace.CloseMe.D1.Handle.Script.Disabled = true
			
		elseif game.Workspace.CloseMe.D1.Opened.Value == false then
			game.Workspace.CloseMe.D1.Opened.Value = true
			game.Workspace.CloseMe.D1.Handle.Script.Disabled = true
		end
		
		game.Workspace.CreepyPaintingArea:Destroy()
		game:GetService("ReplicatedStorage").Storage.OfficeArea.Parent = game.Workspace
		wait(3)
		game.Workspace.Office.Gunshot.Barking:Play()
		game.Workspace.Office.Gunshot.Gun:Play()
		game.Workspace.Office.Gunshot.PointLight.Enabled = true
		wait(0.3)
		game.Workspace.Office.Gunshot.PointLight.Enabled = false
		game.Workspace.CloseMe.D1.Handle.Script.Disabled = false
		script.Parent:Destroy()
end)

2 answers

✓ Accepted answer

User "MouseEnter" instead

function nude()
    kk = game.Workspace.Hello1:GetChildren()
        kkk = game.Workspace.Hello1.D1:GetChildren()
        for i,v in pairs(kk) do
            if v.ClassName == "Part" then
                v.Transparency = 0
                v.CanCollide = true
        end
        end
            for i,v in pairs(kkk) do
                if v.ClassName == "Part" then
                    v.Transparency = 0
                    v.CanCollide = true
                end
            end

            jj = game.Workspace.Hello2:GetChildren()
            jjj = game.Workspace.Hello2.D1:GetChildren()
            for i,v in pairs (jj) do
                if v.ClassName == "Part" then
                    v.Transparency = 0
                    v.CanCollide = true
            end
            end
                for i,v in pairs(jjj) do
                    if v.ClassName == "Part" then
                        v.Transparency = 0
                        v.CanCollide = true
        end
    end
end


Ready = true

script.Parent.ClickDetector.MouseEnter:Connect(function()
        Ready = false
        nude()

        if game.Workspace.CloseMe.D1.Opened.Value == true then
            game.Workspace.CloseMe.D1.Part0.DesiredAngle = 0
            game.Workspace.CloseMe.D1.Opened.Value = false
            game.Workspace.CloseMe.D1.Handle.Script.Disabled = true

        elseif game.Workspace.CloseMe.D1.Opened.Value == false then
            game.Workspace.CloseMe.D1.Opened.Value = true
            game.Workspace.CloseMe.D1.Handle.Script.Disabled = true
        end

        game.Workspace.CreepyPaintingArea:Destroy()
        game:GetService("ReplicatedStorage").Storage.OfficeArea.Parent = game.Workspace
        wait(3)
        game.Workspace.Office.Gunshot.Barking:Play()
        game.Workspace.Office.Gunshot.Gun:Play()
        game.Workspace.Office.Gunshot.PointLight.Enabled = true
        wait(0.3)
        game.Workspace.Office.Gunshot.PointLight.Enabled = false
        game.Workspace.CloseMe.D1.Handle.Script.Disabled = false
        script.Parent:Destroy()
end)

Also instead of saying "if v.ClassName == "Part" then" you should do "if v:IsA("BasePart") then"

1 comment

0

Also wth is with the nude function?

The problem is that MouseHoverEnter isn't a valid member of ClickDetector, to make it work; use MouseEnter instead for the hovering to be detected.

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