Kalananti Game Coding Bootcamp - Camping Survival Game (13-15)

Source Code

Leaderstats
local Players = game:GetService("Players")

function PlayerAdded(Player)
	local Leaderstats = Instance.new("Folder")
	Leaderstats.Name = "leaderstats"
	Leaderstats.Parent = Player
	
	local Sticks = Instance.new("IntValue")
	Sticks.Name = "Sticks"
	Sticks.Parent = Leaderstats
	
	local Oils = Instance.new("IntValue")
	Oils.Name = "Oils"
	Oils.Parent = Leaderstats
end

Players.PlayerAdded:Connect(PlayerAdded)
PickUpScript (Stick)
local Stick = script.Parent
local ClickDetector = Stick.ClickDetector

function Click(Player)
	local Leaderstats = Player:FindFirstChild("leaderstats")

	if Leaderstats then
		Leaderstats.Sticks.Value += 1
		Stick:Destroy()
	end
end

ClickDetector.MouseClick:Connect(Click)
PickUpScript (Oil)
local Oil = script.Parent
local ClickDetector = Oil.ClickDetector

function Click(Player)
	local Leaderstats = Player:FindFirstChild("leaderstats")

	if Leaderstats then
		Leaderstats.Oils.Value += 1
		Oil:Destroy()
	end
end

ClickDetector.MouseClick:Connect(Click)
CampFireScript
local ServerStorage = game:GetService("ServerStorage")

local CampFirePart = script.Parent
local Fire = CampFirePart .Fire
local PointLight = CampFirePart .PointLight
local ClickDetector = CampFirePart .ClickDetector
local CampFireModel = ServerStorage.CampFireModel

function Click(Player)
	local Leaderstats = Player:FindFirstChild("leaderstats")
	local SticksStats = Leaderstats:WaitForChild("Sticks")
	local OilsStats = Leaderstats:WaitForChild("Oils")

	local PlayerGui = Player.PlayerGui
	local ScreenGui = PlayerGui.ScreenGui

	local TextLabel = ScreenGui.TextLabel
	
	if SticksStats.Value >= 5 and OilsStats.Value >= 1 then
		SticksStats.Value = 0
		OilsStats.Value = 0

		local CampFireModelClone = CampFireModel:Clone()
		CampFireModel.Parent = game.Workspace

		Fire.Enabled = true
		PointLight.Enabled = true
		ClickDetector:Destroy()
		BillBoardGui:Destroy()
		
		TextLabel.Position = UDim2.fromScale(0.5, 1.5)

		ScreenGui.Enabled = true

		TextLabel:TweenPosition(
			UDim2.fromScale(0.5, 0.5),
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Back,
			0.5,
			false
		)
	end
end

ClickDetector.MouseClick:Connect(Click)

Starter Project

Starter Project - Camping Survival Game 1315.rbxl (90.1 KB)