#Help

1 messages · Page 1 of 1 (latest)

dawn shell
#

Hey
So i just started to create my game and im kinda new to roblox studio can somebody help me with this code its from chat gpt

-- LocalScript în StarterPlayerScripts

local player = game.Players.LocalPlayer
local gui = player:WaitForChild("PlayerGui"):WaitForChild("CurrencyUI")
local coinsFrame = gui:WaitForChild("CoinsFrame")
local gemsFrame = gui:WaitForChild("GemsFrame")

local coinText = coinsFrame:WaitForChild("CoinText")
local gemText = gemsFrame:WaitForChild("CoinText")

local coins = 100
local gems = 10

local function updateUI()
coinText.Text = tostring(coins)
gemText.Text = tostring(gems)
end

_G.AddCoins = function(amount)
coins += amount
updateUI()
end

_G.AddGems = function(amount)
gems += amount
updateUI()
end

updateUI()
Im trying to make a money system and a gem one but when i type the command to give me coins it doesnt workcrying

dreamy valveBOT
#

studio** You are now Level 1! **studio

viral spade
hollow sphinx
#

while true do

proud prism
# dawn shell Hey So i just started to create my game and im kinda new to roblox studio can so...
-- since u using chatgpt you prob doesnt know where to put this but its in serverscriptservice
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local updateCurrencyUI = ReplicatedStorage:WaitForChild("UpdateCurrencyUI")

local function onPlayerAdded(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local coins = Instance.new("IntValue")
    coins.Name = "Coins"
    coins.Value = 100
    coins.Parent = leaderstats

    local gems = Instance.new("IntValue")
    gems.Name = "Gems"
    gems.Value = 10
    gems.Parent = leaderstats
end

local function giveCoins(player, amount)
    if player and player:FindFirstChild("leaderstats") then
        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + amount
    end
end

-- the comand to give coins in console (if ur dumb)
--game.ServerScriptService.CurrencyManager.GiveCoinsToPlayer(game.Players.YourUsername, 50) 

_G.GiveCoinsToPlayer = function(player, amount)
    giveCoins(player, amount)
end

Players.PlayerAdded:Connect(onPlayerAdded)```

```lua
-- you know where to put this
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local currencyUI = playerGui:WaitForChild("CurrencyUI")

local coinsFrame = currencyUI:WaitForChild("CoinsFrame")
local gemsFrame = currencyUI:WaitForChild("GemsFrame")

local coinText = coinsFrame:WaitForChild("CoinText")
local gemText = gemsFrame:WaitForChild("GemText")

local leaderstats = player:WaitForChild("leaderstats")
local coins = leaderstats:WaitForChild("Coins")
local gems = leaderstats:WaitForChild("Gems")

local function updateUI()
    coinText.Text = tostring(coins.Value)
    gemText.Text = tostring(gems.Value)
end

coins.Changed:Connect(updateUI)
gems.Changed:Connect(updateUI)

updateUI()```
dawn shell
#

I am trying to learn how to script but i didnt find any tutorials on this thats why

rich ore
# dawn shell I am trying to learn how to script but i didnt find any tutorials on this thats ...
dawn shell
#

Do you happen to know if he has a tutorial on how to make a coin system?

rich ore