In many Armies around roblox I’ve always saw this type of thing when I put my mouse near a player:
If somebody knows how to do this, like the group and your rank please comment it. No idea if it’s a system or not
In many Armies around roblox I’ve always saw this type of thing when I put my mouse near a player:
If somebody knows how to do this, like the group and your rank please comment it. No idea if it’s a system or not
To achieve this you can use: UserInputService | Roblox Creator Documentation and GroupService | Roblox Creator Documentation
here is something you can use. all you have to do is replacing a print statement with something that changes text on a gui and you should be good.
local mouse = game.Players.LocalPlayer:GetMouse()
local groups = {
[12898] = "test group 1",
[7060771] = "builderman is noob",
[9699781] = "Grim Productions"
}
game:GetService("RunService").RenderStepped:Connect(function(dt)
local char = mouse.Target:FindFirstAncestorWhichIsA("Model")
if char and char:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(char)
player:GetRankInGroup(2)
for id, name in pairs(groups) do
local rank = player:GetRankInGroup(id)
print("Players rank in ", name, " is ", rank)
end
end
end)
Also im not sure how somebody would use input changed in this.
Nice script! I recommend you instead use string.format for this type of thing
local mouse = game.Players.LocalPlayer:GetMouse()
local groups = {
[12898] = "test group 1",
[7060771] = "builderman is noob",
[9699781] = "Grim Productions"
}
game:GetService("RunService").RenderStepped:Connect(function(dt)
local char = mouse.Target:FindFirstAncestorWhichIsA("Model")
if char and char:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(char)
player:GetRankInGroup(2)
for id, name in pairs(groups) do
local rank = player:GetRankInGroup(id)
print(string.format("Players rank in %s is %s ", name, rank))
end
end
end)
Thanks! I actually have next to no experience with manipulating strings so this is helpful.
It can be used to detect when the mouse is moving.
Yes but how would you know whether or not the mouse is over a player?
local UserInputService = game:GetService("UserInputService")
local GroupService = game:GetService("GroupService")
local Players = game:GetService("Players")
local Groups = {10720185}
local CurrentCamera = workspace.CurrentCamera
UserInputService.InputChanged:Connect(function(input, GPE)
if not GPE then
if input.UserInputType == Enum.UserInputType.MouseMovement then
local MouseLocation = UserInputService:GetMouseLocation()
local unitRay = CurrentCamera:ScreenPointToRay(MouseLocation.X, MouseLocation.Y)
local ray = Ray.new(unitRay.Origin, unitRay.Direction * 250)
local raycastParams = RaycastParams.new()
raycastParams.IgnoreWater = true
local result = workspace:Raycast(ray.Origin, ray.Direction, raycastParams)
if result then
if result.Instance.Parent:FindFirstChild("Humanoid") then
local player = Players:GetPlayerFromCharacter(result.Instance.Parent)
if player then
local userGroups = GroupService:GetGroupsAsync(player.UserId)
for i, group in pairs(userGroups) do
if table.find(Groups, group.Id) then
print(string.format("%s role in the %s group is: %s", player.Name, group.Name, group.Role))
end
end
end
end
end
end
end
end)
Is this a LocalScript or a Normal script?
This seems good but I have no idea about scripting and don’t know if this is a module script, script or local, where do I put this?
It has to be in a localscript and you can put it in StarterPlayer > StarterPlayerScripts
Wow, thats actually a pretty good script. Good job!
local Groups = game:GetService("GroupService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local XProtectedCall = xpcall
local GroupId = 0 --Change to ID of group.
local Debounce = false
Mouse.Move:Connect(function()
if Debounce then
return
end
local RayResult = workspace:Raycast(Mouse.UnitRay.Origin, Mouse.UnitRay.Direction * 100)
if RayResult then
if RayResult.Instance then
if RayResult.Instance:IsA("BasePart") then
local TargetPart = RayResult.Instance
local TargetModel = TargetPart:FindFirstAncestorOfClass("Model")
if TargetModel then
local TargetPlayer = Players:GetPlayerFromCharacter(TargetModel)
if TargetPlayer then
Debounce = true
local Success1, Result1 = XProtectedCall(function()
return TargetPlayer:IsInGroup(GroupId)
end, function(err)
return err
end)
if Success1 then
if Result1 then
print(Result1)
local Success2, Result2 = XProtectedCall(function()
return TargetPlayer:GetRoleInGroup(GroupId)
end, function(err)
return err
end)
if Success2 then
if Result2 then
print(Result2)
end
else
warn(Result2)
end
local Success3, Result3 = XProtectedCall(function()
return TargetPlayer:GetRankInGroup(GroupId)
end, function(err)
return err
end)
if Success3 then
if Result3 then
print(Result3)
end
else
warn(Result3)
end
local Success4, Result4 = XProtectedCall(function()
return Groups:GetGroupInfoAsync(GroupId)
end, function(err)
return err
end)
if Success4 then
if Result4 then
print(Result4)
end
else
warn(Result4)
end
if Result2 and Result3 and Result4 then
local Format = "\nDisplay Name: %s\nUsername: %s\nUser ID: %d\nGroup Name: %s\nGroup ID: %d\nGroup Role: %s\nGroup Rank: %d"
print(Format:format(TargetPlayer.DisplayName, TargetPlayer.Name, TargetPlayer.UserId, Result4.Name, GroupId, Result2, Result3))
end
end
else
warn(Result1)
end
task.wait(1)
Debounce = false
end
end
end
end
end
end)
Starter Player, startplayerscripts?
Yes, a local script inside StarterPlayerScripts.
When I put the cursor in a player that it’s in the group rank doesn’t show up…
it doesn’t work when I put the cursor on a player
The details are printed to the console, there is no gui aspect to it (that’s on you to design).
This is scripting support, not gui support.
Oh, alright thank you I’ll try to figure it out