Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I check for the other Persons rank in this script?

Asked by 4 years ago

In the script below I need to check for the other persons rank. I have a hover over GUI that shows one person the others rank. Here is the code:

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

mouse.Move:Connect(function()
    script.Parent.Position = UDim2.new(0, mouse.X + 10, 0, mouse.Y + 5)
    script.Parent.Visible = false
    local target = mouse.Target
    if target and target.Parent then


        if target.Parent:FindFirstChild("HumanoidRootPart") then
            script.Parent.Text = target.Parent.Name
            script.Parent.Visible = true
        end

        if target:FindFirstChild("Mouseover") then
            script.Parent.Text = target.Mouseover.Value
            script.Parent.Visible = true
        end
    end
end)

It would be very helpful to be told what I should do to show the persons group rank.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I am assuming script.Parent is a TextLabel. You should also consider using UserInputService rather than Mouse, as is it not recommended for new work and UserInputService is more flexible.

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local groupid = () -- put the id of your group in the parentheses

mouse.Move:Connect(function()
    script.Parent.Position = UDim2.new(0, mouse.X + 10, 0, mouse.Y + 5)
    script.Parent.Visible = false
    local target = mouse.Target
    if target and target.Parent then


        if target.Parent:FindFirstChild("HumanoidRootPart") then
            script.Parent.Text = target.Parent.Name
            script.Parent.Visible = true
       tplayer =  target.Parent:GetPlayerFromCharacter(tplayer) -- gets the player from the char
    if tplayer:IsInGroup(groupid) then -- if they are in the group

       PlayerRank = player:GetRoleInGroup(groupid) -- determines their rank
       RankLabel.Text = (PlayerRank.."") -- sets the Labels text to their rank.
        end



        if target:FindFirstChild("Mouseover") then
            script.Parent.Text = target.Mouseover.Value
            script.Parent.Visible = true
        end
    end
end)

Let me know of any errors and I will help you.

0
No, the mouse is better here. UserInputService cannot detect the movement of the mouse cursor. DeceptiveCaster 3761 — 4y
0
^ UIS can detect mouse movement through UIS.InputChanged. pwx 1581 — 4y
0
This is very helpful, the only problem with it is that there are multiple groups that I want to check for their group rank. This code to me looks like I can only get the group rank in one group instead of all the groups. levinsconyers 0 — 4y
Ad

Answer this question