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

Mouse.hit Gui not going away when looking away from object ?

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()


UIS.InputChanged:Connect(function()
	if mouse.Target then
		if mouse.Target.Interact then
			script.Parent.Enabled = true
		else 
			script.Parent.Enabled = false
		end
	end
end)

So basically this script enables a gui if the object has an intvalue called interact in it. But when I look away from that object the gui does not go away. I probably did this very wrong so please help

1 answer

Sorry but I solved my own question....

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()


UIS.InputChanged:Connect(function()
	if mouse.Target then
		if mouse.Target:FindFirstChild('Interact') then
			script.Parent.Enabled = true
		else
			script.Parent.Enabled = false
		end
	end
end)

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