Aller au contenu
— —

Bouton d’achat

Un bouton au sol qui achète un objet du tycoon.

Aussi appelé bouton d’achat de tycoon acheter une machine

C’est quoi ?

Chaque bouton a des attributs Prix et Objet. Quand le propriétaire marche dessus avec assez d’argent, on retire le prix, on clone l’objet depuis ServerStorage et on cache le bouton.

Exemple en Luau
bouton.Touched:Connect(function(hit)
    local j = Players:GetPlayerFromCharacter(hit.Parent)
    if j ~= proprietaire or not bouton.Parent then return end
    local argent = j.leaderstats.Argent
    local prix = bouton:GetAttribute("Prix")
    if argent.Value < prix then return end
    argent.Value -= prix
    local nom = bouton:GetAttribute("Objet")
    ServerStorage.Achats[nom]:Clone().Parent = usine
    bouton.Parent = nil
end)

Erreurs fréquentes

  • Oublier de retirer le bouton tout de suite : deux contacts rapides achètent l’objet deux fois.
Documentation officielle Roblox (en français)

Utilise Bouton d’achat dans ton propre jeu

Avec LearnBlox, tu crées ton jeu Roblox pas à pas, directement dans Roblox Studio. La formation « Les bases » est gratuite et Bloxi t’aide quand tu bloques.

Commencer gratuitement