Is it possible to make a button to share the score? if yes, how?

Godot Version

4.x

Question

How to make a button to share an score on social networks. is it even possible?

You’ll need to find the share link for the social network and use OS.shell_open() to open the link in the user’s browser

Example:

extends Node

const TWITTER_SHARE_URL = "https://twitter.com/intent/tweet?text="


@onready var button: Button = $Button


var score = 9001


func _ready() -> void:
	button.pressed.connect(_on_button_pressed)


func share_twitter() -> void:
	var url = TWITTER_SHARE_URL + ("My highscore in #mygame was: %s" % score).uri_encode()
	OS.shell_open(url)


func _on_button_pressed() -> void:
	share_twitter()
1 Like

Thank you

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.