-
Situation Overview: I am an incredibly amateur scripter, so when I heard people saying the AI program Chat GPT could be used to write roblox scripts I was ecstatic. I tried using it to script a game idea I had called “Corner the Market” in which players are assigned products upon joining the game and have to compete with other players to make the most money. After prompting Chat GPT to create the script I had in mind to assign each player a product and increase their score based on if another player in the game had the product, I was impressed with the result. To me (the amateur scripter) it seemed on the right track; however, it doesnt work at all.
-
Issue: The script does not increase the player’s “Score” stat every second by either 10 or 5 upon the player joining the game.
-
Solutions Tried: I added a few lines of code the script to create the leaderboard and Score stat, and made sure the script was placed in ServerScriptService.
game.Players.PlayerAdded:Connect (function(player)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local score = Instance.new("IntValue", stats)
score.Name = "Score"
stats.Parent = player
end)
-- Create a table of the four words
local words = {"Clocks", "Fans", "Lamps", "Hats"}
-- Function to assign a word to a player and set up their score tracking
local function assignWord(player)
-- Assign a random word to the player
local word = words[math.random(#words)]
player.Word = word
-- Set up a score tracking function for the player
local function trackScore(player)
-- Increase the player's score by 10 if they are the only one with their word
if game.Players:GetPlayers(player.Word) == player then
player.leaderstats.Score.Value = player.leaderstats.Score.Value + 10
-- Otherwise, increase the score by 5
else
player.leaderstats.Score.Value = player.leaderstats.Score.Value + 5
end
end
-- Run the score tracking function every second
player.Heartbeat:Connect(function()
trackScore(player)
end)
end
-- Assign a word to each player when they join the game
game.Players.PlayerAdded:Connect(function(player)
assignWord(player)
end)
I understand that it could be controversial to use a chat bot to write scripts for you since you don’t have to do much work, but I think it could be a great resource for aspiring scripters like myself.