Your code looks okay; it's probably a problem with god forsaken capitalization (and therefore paths to objects in the game hierarchy).
Working in a FilteringEnabled, non-experimental game:
local player = game.Players.LocalPlayer;
local mouse = player:GetMouse();
mouse.Move:connect(function()
if(mouse.Target ~= nil)then
if(mouse.Target == game.Workspace.Baseplate)then
player.PlayerGui.ScreenGui.Frame.Visible = true;
else
if(player.PlayerGui.ScreenGui.Frame.Visible == true)then
player.PlayerGui.ScreenGui.Frame.Visible = false;
end
end
end
end)
I would recommend looking into UserInputService as well, which features (for example) checks on whether an event was processed by the Roblox client.
http://wiki.roblox.com/index.php?title=API:Class/UserInputService
Arguably better code:
local player = game.Players.LocalPlayer;
local mouse = player:GetMouse();
local inputservice = game:GetService("UserInputService");
inputservice.InputChanged:connect(function(input, handled)
if((input.UserInputType == Enum.UserInputType.MouseMovement) and not handled)then
if(mouse.Target ~= nil)then
if(mouse.Target == game.Workspace.Baseplate)then
player.PlayerGui.ScreenGui.Frame.Visible = true;
else
if(player.PlayerGui.ScreenGui.Frame.Visible == true)then
player.PlayerGui.ScreenGui.Frame.Visible = false;
end
end
end
end
end)
1 comment
@NeonHaxOfficial Does it work in studio?