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

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

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

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.

3 comments

0

No, the mouse is better here. UserInputService cannot detect the movement of the mouse cursor.

0

^ UIS can detect mouse movement through UIS.InputChanged.

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.

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