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

I have a script but it doesnt work, how can I get it to work with Filtering Enabled?

Asked by 5 years ago
Edited 5 years ago

CORRECTION: The script does work, but how can I get it to display the GUI right next to the mouse, and display their rank in a group as well?

local Player=game.Players.LocalPlayer
local gui = script.Parent.Frame

repeat wait() until Player and Player.Character and wait(5)

local Character=Player.Character
local mouse=Player:GetMouse()
local hoverPlayer = false

mouse.Move:connect(function()
    if mouse.Target ~= nil then
        local humanoid, player = mouse.Target.Parent:findFirstChild("Humanoid"), game.Players:FindFirstChild(mouse.Target.Parent.Name)
        if humanoid and player then
            if not hoverPlayer then
                gui.NameLabel.TextColor3 = player.TeamColor.Color
                gui.NameLabel.Text = humanoid.Parent.Name
                gui.HealthLabel.Text = math.ceil(mouse.Target.Parent.Humanoid.Health / mouse.Target.Parent.Humanoid.MaxHealth * 100) .."%" 
                hoverPlayer = true      
            end
        else
            hoverPlayer = false     
            gui.NameLabel.Text = ""
            gui.HealthLabel.Text = ""
        end
    end
end)

0
So your issue is solved? oreoollie 649 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Basically, when you turn Filtering Enabled on you are disconnecting the Client and Server side of your game. Your script here is on the Client side since you are using the Mouse object from the player. And now you want to hover over another player and get their name and health. To get the health of a player you are going to need their Humanoid, and where is that? That is on the server side. So in order to access it, you will need to Invoke the server using a Remote Function which will connect you to the server and return the value you need.

Here are two resources for you, devforum.roblox.com/t/what-is-filteringenabled/67927 wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

0
The issue wasnt that it wont display health or anything, the issue was it wouldnt display the GUI at all, however I fixed that. ResoluteAyres 6 — 5y
Ad

Answer this question