Creating Your First Game in Roblox Studio - Part #4 - Adding Scores
Creating Your First Game in Roblox Studio - Part #4 - Adding Scores
1. Watch the previous video
Creating Your First Game in Roblox Studio - Part #1 - Creating Disappearing Part
https://youtu.be/IEddAzLIEa0
Creating Your First Game in Roblox Studio - Part #2 - Creating Lava Floor to Kill Player
https://youtu.be/QUUSvC5T2y8
Creating Your First Game in Roblox Studio - Part #3 - Adding a Fading Trap
https://youtu.be/5PlFcXQY3Lw
2. In ServerScriptService, create a script called SetupPoints.
3. Write down the scripts
local Players = game:GetService("Players")
local function onCharacterAdded(character, player)
player:SetAttribute("IsAlive", true)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
local points = player.leaderstats.Points
points.Value = 0
player:SetAttribute("IsAlive", false)
end)
end
local function onPlayerAdded(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
player:SetAttribute("IsAlive", false)
player.CharacterAdded:Connect(function(character)
onCharacterAdded(character, player)
end)
end
Players.PlayerAdded:Connect(onPlayerAdded)
while true do
wait(1)
local playerList = Players:GetPlayers()
for i = 1, #playerList do
local player = playerList[i]
if player:GetAttribute("IsAlive") then
local points = player.leaderstats.Points
points.Value = points.Value + 1
end
end
end
4. The code will add a timer to automatically add the score so the longer the player can stay alive, more scores he will get :) The score will be reset when the player dies
next time we will learn how to make score based on touch or when you shot an object ;)
thanks for watching, don’t forget to subscribe, activate the notification bell, like this video and also share it to support this channel to be able to continuously create useful tutorials :)
leave us some comments if there is any questions and let us know what you think :)
Intro and Outro created by ProCodeCG Kids: Islamey Fawwaz Alfattan
visit our website: http://procodecg.com
and blog: https://procodecg.wordpress.com
and follow us on Instagram: https://www.instagram.com/procodecg/
Twitter: https://twitter.com/procodecg
Facebook: http://facebook.com/procodecg/
Видео Creating Your First Game in Roblox Studio - Part #4 - Adding Scores канала ProCode CG
1. Watch the previous video
Creating Your First Game in Roblox Studio - Part #1 - Creating Disappearing Part
https://youtu.be/IEddAzLIEa0
Creating Your First Game in Roblox Studio - Part #2 - Creating Lava Floor to Kill Player
https://youtu.be/QUUSvC5T2y8
Creating Your First Game in Roblox Studio - Part #3 - Adding a Fading Trap
https://youtu.be/5PlFcXQY3Lw
2. In ServerScriptService, create a script called SetupPoints.
3. Write down the scripts
local Players = game:GetService("Players")
local function onCharacterAdded(character, player)
player:SetAttribute("IsAlive", true)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
local points = player.leaderstats.Points
points.Value = 0
player:SetAttribute("IsAlive", false)
end)
end
local function onPlayerAdded(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
player:SetAttribute("IsAlive", false)
player.CharacterAdded:Connect(function(character)
onCharacterAdded(character, player)
end)
end
Players.PlayerAdded:Connect(onPlayerAdded)
while true do
wait(1)
local playerList = Players:GetPlayers()
for i = 1, #playerList do
local player = playerList[i]
if player:GetAttribute("IsAlive") then
local points = player.leaderstats.Points
points.Value = points.Value + 1
end
end
end
4. The code will add a timer to automatically add the score so the longer the player can stay alive, more scores he will get :) The score will be reset when the player dies
next time we will learn how to make score based on touch or when you shot an object ;)
thanks for watching, don’t forget to subscribe, activate the notification bell, like this video and also share it to support this channel to be able to continuously create useful tutorials :)
leave us some comments if there is any questions and let us know what you think :)
Intro and Outro created by ProCodeCG Kids: Islamey Fawwaz Alfattan
visit our website: http://procodecg.com
and blog: https://procodecg.wordpress.com
and follow us on Instagram: https://www.instagram.com/procodecg/
Twitter: https://twitter.com/procodecg
Facebook: http://facebook.com/procodecg/
Видео Creating Your First Game in Roblox Studio - Part #4 - Adding Scores канала ProCode CG
Комментарии отсутствуют
Информация о видео
16 мая 2022 г. 17:48:12
00:02:36
Другие видео канала