Ok. So I am basically branching of of FastSnail5's question. But mine is different. How do you make the textlabel's text the players name when you hover over a player? Here is my script from RavenShield. I just don't know what to make the target or if I just have to change the whole entire script. (This is a local script)
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
03 | local target = game.Players -- Don't know what the target should be... |
04 | local label = player.PlayerGui.HoverGUI.Frame.TextLabel |
05 |
06 | mouse.Move:connect( function () |
07 | if mouse.Target and mouse.Target:IsDescendantOf(target) then |
08 | label.Text = target.Name |
09 | label.Visible = true |
10 | else |
11 | label.Visible = false |
12 | label.Text = "" |
13 | end |
14 | end ) |
Try this:
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
03 | local label = player.PlayerGui.HoverGUI.Frame.TextLabel |
04 |
05 | mouse.Move:connect( function () |
06 | local target = mouse.Target |
07 | if target and target.Parent and game.Players:FindFirstChild(target.Parent.Name) then |
08 | local otherPlayer = game.Players:FindFirstChild(target.Parent.Name) |
09 | label.Text = otherPlayer.Name |
10 | label.Position = UDim 2. new(mouse.X, mouse.Y) |
11 | label.Visible = true |
12 | else |
13 | label.Visible = false |
14 | end |
15 | end ) |
That should work.
PLEASE UPVOTE IF THIS ANSWER IS GOOD!
You could've just messaged me, but I'll give a helping hand anyway.
What you want to do is take use of Mouse.Target, and see if Mouse.Target is child of either players' character. Assuming a player's character is built up by parts inside a model, you can take use of game.Players:GetPlayerFromCharacter(model) to verify if the target actually is a player. http://wiki.roblox.com/index.php?title=API:Class/Players/GetPlayerFromCharacter
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
03 | local label = player.PlayerGui.HoverGUI.Frame.TextLabel |
04 |
05 | mouse.Move:connect( function () |
06 | if mouse.Target and game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then |
07 | label.Text = mouse.Target.Parent.Name |
08 | label.Visible = true |
09 | else |
10 | label.Visible = false |
11 | label.Text = "" |
12 | end |
13 | end ) |
bruh idk why u put so many lines, make a textlabel in your screengui and make a local script into the textlabel and just put this:
local player = game.Players.LocalPlayer.Name
script.Parent.Parent.TextLabel.Text = player
oh and bro, i just tried to help you make a little script if u want something advanced sorry but that's how it worked for me