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

I want to make so if you enter the mouse on a block a gui will opens?

Hello,

I want to make so if the mouse target a brick a gui will be visible but its not working

This is the script i using now;

local player = game.Players.Localplayer
Mouse = player:GetMouse()

if Mouse.Target == "Part" then
player.PlayerGui.ScreenGui.Frame.Visible = true
end

1 answer

That is wrong in a couple ways.

  1. Mouse.Target is an object, so you should be looking for workspace.Part instead of "Part"

  2. Your script will only update once, and that's when the script first loads. You want to add in a part where the script will constantly update whenever the mouse is moved. Like so:

local player = game.Players.Localplayer
Mouse = player:GetMouse()

Mouse.Move:Connect(function()
	if Mouse.Target == workspace.Part then
		player.PlayerGui.ScreenGui.Frame.Visible = true
	end
end)

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