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

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

Asked by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago
Edited 2 years ago

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 ;-;

0
0
StarterGui is cloned into playerGUI when you join so you need to make the script change the local players PlayerGUI not starterGui Robb12 12 — 4y
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. SteamG00B 1633 — 4y
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 Xapelize 2658 — 4y
View all comments (5 more)
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" SteamG00B 1633 — 4y
0
That doesn't work for me ;-; so please make a clearer explains and let me accept the answer too ;c Xapelize 2658 — 4y
0
WARNING : THE PLAYER GUI MUST GET :WaitForChild("PlayerGui") or it will not works Xapelize 2658 — 4y
0
But plz make it an answer ;c Xapelize 2658 — 4y
0
You actually don't need to do WaitForChild unless you are unsure if the character has loaded in. SteamG00B 1633 — 4y

1 answer

Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
4 years ago
Edited 4 years ago
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.

0
Nvm :D Thanks for helping! But I'm so sorry because this script won't work for me :( Keep the good work ;D Xapelize 2658 — 4y
0
Should i put this in a LocalScript? :3 Xapelize 2658 — 4y
0
If it is a script in the workspace, it should always be a regular script. SteamG00B 1633 — 4y
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. SteamG00B 1633 — 4y
Ad

Answer this question