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

Getting players humanoid from server script?

Hello everybody its been quite a while since I last posted a question here but I have come to a stone wall where I'm not sure as to how to go about finishing my Anticheat system as I need it to run the checks on the server side so players can't just bypass the exploit system, below I have listed what I currently have any help/explanation of how to go about doing this would be great!

I have been trying to work on this system for almost 10 hours now using different methods but only had one that worked but it only showed the message locally to the local players' chat, not server-side.

Server Script

local player = game.Players.LocalPlayer
local character = player.Character
local Humanoid = character:FindFirstChild("Humanoid")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ExploitAlerts = ReplicatedStorage:WaitForChild("ExploitAlerts")

function exploitsystem()
	if Humanoid.WalkSpeed > 16 then
		     Humanoid.WalkSpeed = 16
		ExploitAlerts:FireAllClients("Speed Exploiting")
	end
end

Humanoid.StateChanged:Connect(exploitsystem)

Local Script within starter gui

local Humanoid =script.Parent:FindFirstChild("Humanoid")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ExploitAlerts = ReplicatedStorage:WaitForChild("ExploitAlerts")

ExploitAlerts.OnClientEvent:Connect(function(player, exploitname)
	local bc = BrickColor.new("Bright red")
game.StarterGui:SetCore("ChatMakeSystemMessage", {
    Text = "[SYSTEM] "..player.Name.."is possibly "..exploitname.." please call a moderator!";
    Font = Enum.Font.Cartoon;
    Color = bc.Color;
    FontSize = Enum.FontSize.Size96;   
})
end)

2 comments

0

I'm kind of confused by this. Last I checked you couldn't get the "LocalPlayer" in a .. server script.. isn't the whole point of a server script that it /isn't/ local?

0

Also beyond that, try taking the event out of ReplicatedStorage and putting it in workspace or something. Just a hunch.

1 answer

Try This:

Server Script:

while wait() do
for i,v in pairs(game.Players:GetPlayers()) do
if v.Character ~= nil then
if v:FindFirstChildOfClass"Humanoid" then
if v:FindFirstChildOfClass"Humanoid".WalkSpeed > 16 then
local rs = game:GetService"ReplicatedStorage"
local remote = rs:WaitForChild"ExploitAlerts"
local plrname = v.Name
remote:FireAllClients(plrname.." Was Detected Exploiting!")
-- // If You Want To Kick The Exploiter Then Uncomment The Line Below \\ --
--v:Kick("Do Not Use Speed Exploits!")
end
end
end
end
end

Local Script In Starter Gui:

local rs = game:GetService"ReplicatedStorage"
local remote = rs:WaitForChild"ExploitAlerts"
-- // Make Chat Message \\ --
remote.OnClientEvent:Connect(function(msg)
local bc = BrickColor.new("Bright red")
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[SYSTEM] "..msg.." Please Call A Moderator!";
Font = Enum.Font.Cartoon;
Color = bc.Color;
FontSize = Enum.FontSize.Size96;   
})
end)

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