New Hills

 avatar
unknown
plain_text
10 months ago
1.1 kB
15
Indexable
-- New Hills RP Core (Server)
-- Place this Script in ServerScriptService

local Players = game:GetService("Players")

-- Helper: set RP display name safely
local function setRPName(player, newName)
    if player.Character and player.Character:FindFirstChild("Humanoid") then
        -- Limit length and strip leading/trailing spaces
        newName = string.sub(string.gsub(newName, "^%s*(.-)%s*$", "%1"), 1, 25)
        if newName == "" then newName = player.Name end
        player.Character.Humanoid.DisplayName = newName
    end
end

Players.PlayerAdded:Connect(function(player)
    -- Spawn character and set a friendly default RP name
    player:LoadCharacter()
    player.CharacterAdded:Connect(function()
        setRPName(player, player.Name .. " ✦ New Hills")
    end)

    -- Chat command: /name Your RP Name
    player.Chatted:Connect(function(message)
        -- Case-insensitive check; command format: /name <text>
        local prefix = string.sub(message, 1, 6):lower()
        if prefix == "/name " then
            local newName = string.sub(message, 7)
            setRPName(player, newName)
        end
    end)
end)
Editor is loading...
Leave a Comment