#How Can I Change Players' Names With Script?

1 messages · Page 1 of 1 (latest)

gusty wharf
#

name is not changeable, but nameTag is

#
player.nameTag = 'custom Name 129'
wanton lichen
#

what do you not understand

#

this is a example he's showing, it's up to you to implement it where in your code you need it

#

@hard yoke

tulip gull
#

@hard yoke
import { world } from '@minecraft/server'
function getNicks(player) {
let nickPrefix = 'nick:'
let defaultNick = player.name

const nicks = player.getTags().map((tags) => {
    if (!tags.startsWith(nickPrefix)) return null
    return tags.substring(nickPrefix.length)
}).filter((tag) => tag)

return nicks.length == 0 ? [defaultNick] : nicks

}

world.beforeEvents.chatSend.subscribe((data) => {
let player = data.sender
let content = data.message

data.cancel = true
world.sendMessage(${getNicks(player)}: §f${content}`)

})

#

try that

#

use /tag