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

How do I make the Gui appears when my mouse hovered it?

Please note this is a old post, so the time when I posted this I was a noob, please don't complain

Ok, I checked the script, that wasn't any error, but I have no idea why the script doesn't work.

script.Parent.ClickDetector.MouseHoverLeave:Connect(function(Player)
   game.StarterGui.GunShop.Enabled = false
end)
 
script.Parent.ClickDetector.MouseHoverEnter:Connect(function(Player)
   game.StarterGui.GunShop.Enabled = true
end)

I'd think the game does error, BUT I tested another script like this, it WORKED??! :

script.Parent.ClickDetector.MouseHoverLeave:Connect(function(Player)
   print("Hover out")
end)
 
script.Parent.ClickDetector.MouseHoverEnter:Connect(function(Player)
   print("Hover in")
end)

Every help is appreciated.

Edit :

script.Parent.ClickDetector.MouseHoverLeave:Connect(function(Player)
   game.Players.LocalPlayer.PlayerGui.GunShop.Enabled = false
end)

script.Parent.ClickDetector.MouseHoverEnter:Connect(function(Player)
   game.Players.LocalPlayer.PlayerGui.GunShop.Enabled = true
end)

This script won't work for me ;-;

9 comments

0

StarterGui is cloned into playerGUI when you join so you need to make the script change the local players PlayerGUI not starterGui

0

Best thing to do when working with screen guis is to run the game and either just do small edits there while it is running (which I don't recommend) or use snipping tool to take a picture of what the hierarchy looks like in-game.

0

Omg thx for helps, And can you do the script for me? I tested a lot but all doesn't work. Thanks you :D

0

We've given you everything you need to fix it yourself, there's no need for us to do it for you. Just change the hierarchy in your script from "game.StarterGui" to "game.Players.LocalPlayer.PlayerGui"

0

That doesn't work for me ;-; so please make a clearer explains and let me accept the answer too ;c

0

WARNING : THE PLAYER GUI MUST GET :WaitForChild("PlayerGui") or it will not works

0

But plz make it an answer ;c

0

You actually don't need to do WaitForChild unless you are unsure if the character has loaded in.

1 answer

script.Parent.ClickDetector.MouseHoverLeave:Connect(function(Player)
   Player.GunShop.Enabled = false
   print("hover left")
end)

script.Parent.ClickDetector.MouseHoverEnter:Connect(function(Player)
   Player.GunShop.Enabled = true
   print("hover enter")
end)

Since the MouseHover functions already give you which player has hovered their mouse over the click detector, you don't need to do any of that stuff we talked about in comments, you just need to get the Player in the function argument's GunShop GUI.

This script will work, and if it prints both "hover enter" and "hover left", then the only reason it doesn't work is because there's something wrong with the GunShop GUI.

4 comments

0

Nvm :D Thanks for helping! But I'm so sorry because this script won't work for me :( Keep the good work ;D

0

Should i put this in a LocalScript? :3

0

If it is a script in the workspace, it should always be a regular script.

0

If this doesn't work for you, then you need to check your hierarchy and your shop gui because this script does answer your question.

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