Hi. I am very new to lua coding, so please tell me what I can do to improve. Anyway, I am trying to make a script that makes the player have a value that goes higher every 5 minutes. When it reaches 5, the player gets a sword. Whenever I test it in game, the script won't start. Please tell me what is wrong with this script, how I can fix it, and how to make the script start.
local plrs = game:GetService("Players")
local insanity = script.Insanity
local tool = game.ServerStorage.ClassicSword
local clone = tool:Clone()
local plr = game.Players.LocalPlayer
function onPlayerEntered(newPlayer)
print("Script started")
insanity.Value = 1
wait(20)
print("yep the dude is going insane")
game.StarterGui.ScreenGui.Frame.Visible = true
wait(10)
game.StarterGui.ScreenGui.Frame.Visible = false
insanity.Value = 2
wait(300)
insanity.Value = 3
wait(300)
insanity.Value = 4
wait(300)
insanity.Value = 5
end
if insanity.Value then
if clone.Parent ~= plr.Backpack then
clone.Parent = plr.Backpack
end
end
