#how to make form function say hello
1 messages · Page 1 of 1 (latest)
player.sendMessage(“hello”)
I've tried it but it doesn't work
try removing player in parentheses function
can you send your code so I can edit it?
function hello(player) {
const f = new ActionFormData()
f.title('hello')
f.body('hello')
f.button('hello')
f.show(player).then((r) => {
const selection = r.selection
})
}
world.afterEvents.itemUse.subscribe((r) => {
const player = r.source
const item = r.itemStack.typeId
if (item === "minecraft:compass") {
hello(player)
}
})
Yeah ik but it will nested and hard to read
yes I agree but does it work without the function
if so I could look into putting it in a function afterwards
Welp the function only can show the form
No
I'm on my phone I don't have my scripts to give you an example that would work 100% but I assure you that it works
Yeah ik it but I don't know how to make it
but just your consistency until the end of your function instead of the name of your function
Hmm do you think asynchronous may work ?
I already did it in the past it worked after now I use functions
So how you do it
like that
Uhh okay can you send the example code
when I have my PC
import { world } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";
function hello(player) {
const form = new ActionFormData()
form.title('hello')
form.body('hello')
form.button('hello')
form.show(player).then(result => {
if (result.selection === 0) {
player.runCommandAsync('execute as @a at @s run summon snowball ~ ~ ~')
player.sendMessage(`§aHello!`)
}}
)}
world.afterEvents.itemUse.subscribe((r) => {
const player = r.source
const item = r.itemStack.typeId
if (item === "minecraft:compass") {
hello(player)
}
})
@uncut plover