#InvokeServer Error

11 messages · Page 1 of 1 (latest)

paper eagle
#

Newbie scripter here!! Please help I thought I did everything right and I can't find the problem with my script. I was following a yt tutorial

#

Please wait while I post the script

#

This is the leaderstat script vvvvvv

#
    local leaderstats = Instance.new("Folder", plr)
    leaderstats.Name = "leaderstats"
    
    local coins = Instance.new("IntValue",leaderstats)
    coins.Name = "Coins"
    coins.Value = 50
end)

local Prices = {
    sword = 30,
    gun = 60,
    magicwand = 20,
    shield = 30
}

local PurchaseButtonRemote = game.ReplicatedStorage.PurchaseButtonRemote

PurchaseButtonRemote.OnServerInvoke = function(plr, item)
    local PurchaseSuccess = false
    
    local leaderstat = plr.leaderstats
    local Coins = leaderstat.Coins
    
    if Coins.Value >= Prices[item] then
        Coins.Value -= Prices[item]
        PurchaseSuccess = true
        
    end
    
    return PurchaseSuccess
end```
#
local gui = script.Parent

local SwordButton = gui.Sword
local MagicwandButton = gui.MagicWand
local ShieldButton = gui.Shield
local GunButton = gui.Gun

local PurchaseButtonRemote = game.ReplicatedStorage.PurchaseButtonRemote



SwordButton.MouseButton1Click:Connect(function()
    local PurchaseSuccess = SwordButton:InvokeServer("sword")
    
    print(PurchaseSuccess)
end)


#

This is the button script that I was testing

paper eagle
blissful wedge
#

SwordButton
is a guibutton, not a remotefunction

paper eagle
#

thanks

full stratusBOT
#

studio** You are now Level 4! **studio