Help with UserInputService

So i was planning to make a info frame for when a player is hovering my button and i did make this

local thing=Instance.new('TextLabel')
local ss=Instance.new('ScreenGui')
local contain=Instance.new('Frame')
contain.Size=UDim2.fromOffset(500,80)
ss.Parent=game:GetService'Players'.LocalPlayer:WaitForChild'PlayerGui'
thing.Size=UDim2.fromOffset(150,50)
thing.AnchorPoint=Vector2.new(.5,.5)
contain.InputBegan:Connect(function(input)
  thing.Visible=true
  thing.Position=UDim2.fromOffset(input.Position.X+120,input.Position.Y)
  thing.Text=tostring(input.UserInputType):sub(rawlen('Enum.UserInputType.')+1,rawlen(tostring(input.UserInputType)))
end)
contain.InputChanged:Connect(function(input)
  thing.Position=UDim2.fromOffset(input.Position.X+120,input.Position.Y)
  thing.Text=tostring(input.UserInputType):sub(rawlen('Enum.UserInputType.')+1,rawlen(tostring(input.UserInputType)))
end)
contain.InputEnded:Connect(function(input)
  thing.Visible=false
end)
thing.Parent=contain
contain.Parent=ss
thing.BackgroundColor3=Color3.fromRGB(47,47,47)
thing.Text='Waiting For An Input'
thing.TextColor3=Color3.fromRGB(0,121)

But i want to know if there is a better way to do this ?

ā€˜TextButtonsā€™ (or any buttons in general) use a function called ā€˜MouseEnterā€™, I think this will be useful for you.

I donā€™t think if mouseEnter returns an input right ? Or am i wrong ?

Oh, sorry. I didnā€™t even notice you were trying to get an input! (Iā€™m on phone) I donā€™t think thereā€™s another way of getting an input other than getting it through InputBegan, InputChanged and InputEnded. So in this case there is no other way of improving the script you already have. (I always say ā€œif it works it worksā€)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.