Загрузка данных


--[[
    POINTS SERVER TESTER v1
    Intended for testing your own Roblox place.

    One button:
      1) Tests local Points modification.
      2) Finds only point-related remotes.
      3) Tries a few common server payload shapes.
      4) Logs everything to console.

    IMPORTANT:
      - A client cannot directly edit server memory.
      - Server-side change is only possible if your game exposes a RemoteEvent/
        RemoteFunction that trusts client input.
]]

print("[POINTS TEST] 01 script entered")

local Players = game:GetService("Players")

local player = Players.LocalPlayer
if not player then
    warn("[POINTS TEST] LocalPlayer unavailable")
    return
end

local playerGui = player:WaitForChild("PlayerGui")
local leaderstats = player:WaitForChild("leaderstats", 10)

if not leaderstats then
    warn("[POINTS TEST] leaderstats not found")
    return
end

local points = leaderstats:WaitForChild("Points", 10)
if not points or not points:IsA("ValueBase") then
    warn("[POINTS TEST] leaderstats.Points not found")
    return
end

print("[POINTS TEST] 02 Points found:", points:GetFullName(), "value=", points.Value)

local old = playerGui:FindFirstChild("points_server_tester")
if old then
    old:Destroy()
end

local gui = Instance.new("ScreenGui")
gui.Name = "points_server_tester"
gui.ResetOnSpawn = false
gui.IgnoreGuiInset = true
gui.DisplayOrder = 999999
gui.Parent = playerGui

local button = Instance.new("TextButton")
button.Name = "audit"
button.Size = UDim2.fromOffset(180, 52)
button.Position = UDim2.fromOffset(18, 90)
button.BackgroundColor3 = Color3.fromRGB(190, 58, 58)
button.BorderSizePixel = 0
button.Text = "TEST POINTS"
button.TextColor3 = Color3.new(1, 1, 1)
button.TextSize = 17
button.Font = Enum.Font.GothamBold
button.Parent = gui

print("[POINTS TEST] 03 button created")

local running = false

local function lower(s)
    return string.lower(tostring(s))
end

local function isPointRemote(obj)
    if not (obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction")) then
        return false
    end

    local path = lower(obj:GetFullName())
    local name = lower(obj.Name)

    return string.find(path, "point", 1, true) ~= nil
        or string.find(name, "score", 1, true) ~= nil
end

local function classifyPayload(remoteName, current)
    local n = lower(remoteName)

    if string.find(n, "add", 1, true)
        or string.find(n, "give", 1, true)
        or string.find(n, "reward", 1, true)
        or string.find(n, "increment", 1, true)
    then
        return 7, "delta"
    end

    return current + 17, "absolute"
end

local function firePattern(remote, label, args)
    print("[POINTS TEST] TRY", remote:GetFullName(), "|", label)

    if remote:IsA("RemoteEvent") then
        local ok, err = pcall(function()
            remote:FireServer(table.unpack(args))
        end)

        if ok then
            print("[POINTS TEST] SENT", label)
        else
            warn("[POINTS TEST] ERROR", label, tostring(err))
        end
        return
    end

    if remote:IsA("RemoteFunction") then
        task.spawn(function()
            local ok, result = pcall(function()
                return remote:InvokeServer(table.unpack(args))
            end)

            if ok then
                print("[POINTS TEST] INVOKE RETURN", label, tostring(result))
            else
                warn("[POINTS TEST] INVOKE ERROR", label, tostring(result))
            end
        end)
    end
end

local function runTest()
    if running then
        warn("[POINTS TEST] already running")
        return
    end

    running = true
    button.Text = "RUNNING..."

    local original = points.Value

    print("==================================================")
    print("[POINTS TEST] START")
    print("[POINTS TEST] original Points =", original)

    if typeof(original) ~= "number" then
        warn("[POINTS TEST] Points is not numeric; test stopped")
        button.Text = "TEST POINTS"
        running = false
        return
    end

    -- Local-only write.
    local localTarget = original + 111
    local okLocal, errLocal = pcall(function()
        points.Value = localTarget
    end)

    if okLocal then
        print("[POINTS TEST] LOCAL WRITE:", original, "->", points.Value)
    else
        warn("[POINTS TEST] LOCAL WRITE ERROR:", tostring(errLocal))
    end

    task.wait(0.5)

    local candidates = {}
    for _, obj in ipairs(game:GetDescendants()) do
        if isPointRemote(obj) then
            table.insert(candidates, obj)
        end
    end

    print("[POINTS TEST] point-related remotes found =", #candidates)

    if #candidates == 0 then
        warn("[POINTS TEST] No point-related RemoteEvent/RemoteFunction found.")
    else
        for _, remote in ipairs(candidates) do
            local payload, mode = classifyPayload(remote.Name, original)

            print("--------------------------------------------------")
            print("[POINTS TEST] REMOTE:", remote:GetFullName())
            print("[POINTS TEST] class =", remote.ClassName, "| mode =", mode, "| payload =", payload)

            firePattern(remote, "number", {payload})
            task.wait(0.15)

            firePattern(remote, "Points + number", {"Points", payload})
            task.wait(0.15)

            firePattern(remote, "points + number", {"points", payload})
            task.wait(0.35)
        end
    end

    print("--------------------------------------------------")
    print("[POINTS TEST] waiting for server replication...")

    local beforeWait = points.Value
    task.wait(3)
    local finalValue = points.Value

    print("[POINTS TEST] value before wait =", beforeWait)
    print("[POINTS TEST] value after 3 sec =", finalValue)

    if finalValue ~= beforeWait then
        warn("[POINTS TEST] VALUE CHANGED AFTER REMOTE TEST:", beforeWait, "->", finalValue)
        warn("[POINTS TEST] This may indicate server replication or another game system changed Points.")
    else
        print("[POINTS TEST] No visible server-side change detected.")
        print("[POINTS TEST] Current value may be only the local client copy.")
    end

    print("[POINTS TEST] END")
    print("==================================================")

    button.Text = "TEST POINTS"
    running = false
end

button.MouseButton1Click:Connect(runTest)
button.Activated:Connect(runTest)

print("[POINTS TEST] READY - press TEST POINTS")