You need to use a RemoteEvent to communicate with from client to server
So first add a RemoteEvent in ReplicatedStorage
Now in your LocalScript put in the following:
local RP = game:GetService("ReplicatedStorage")
local Event = RP:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
if Hidden == false then
Hidden = true
player.PlayerGui.INFO.NameDi.Text = "Name Hidden: TRUE"
Event:FireServer(Hidden)
end
and now add a Script in ServerScriptService and put in the following:
local RP = game:GetService("ReplicatedStorage")
local Event = RP:FindFirstChild("RemoteEvent")
Event.OnServerEvent:Connect(function(player, bool)
if bool == false then
player.HealthDisplayDistance = 10
player.NameDisplayDistance = 10
else
player.HealthDisplayDistance = 0
player.NameDisplayDistance = 0
end
end)
Didn't test it but it should work unless there was a typo, if there are any errors just tell me and I'll correct them : )