I want to make a game similiar to wolves, if you know it then you also know it includes roles!
that part im confused on, cause i do want to assign roles to people randomly AND with a limit for each role but i do not know how
game script so far
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local function BeginGame()
for i = 20, 0, -1 do
task.wait(1)
ReplicatedStorage.Status.Value = "Intermission:"..i
end
ReplicatedStorage.Status.Value = "Night Phase"
end
BeginGame()
local script under the text label
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TimeLabel = script.Parent
ReplicatedStorage.Status.Changed:Connect(function()
TimeLabel.Text = ReplicatedStorage.Status.Value
end)
for data saving/loading
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local WinsDataStore = DataStoreService:GetDataStore("Data")
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Wins = Instance.new("IntValue")
Wins.Name = "Wins"
Wins.Parent = leaderstats
local RoleString = Instance.new("StringValue")
RoleString.Name = "Role"
RoleString.Parent = player
RoleString.Value = ""
local success, CurrentWins = pcall(function()
return WinsDataStore:GetAsync(player.UserId)
end)
if success and CurrentWins then
Wins.Value = CurrentWins
else
Wins.Value = 0
end
end)
local function SaveData(player)
local Wins = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Wins")
if Wins then
local success, err = pcall(function()
WinsDataStore:UpdateAsync(player.UserId, function(oldValue)
return Wins.Value
end)
end)
if not success then
warn("Failed to save data for " .. player.Name .. ": " .. err)
end
end
end
Players.PlayerRemoving:Connect(SaveData)
task.spawn(function()
while task.wait(600) do
for i, player in pairs(Players:GetPlayers()) do
SaveData(player)
end
end
end)
the roles ive made in the replicatedstorage
local Roles = {
Villager = {
Team = "Village",
Ability = nil
},
Werewolf = {
Team = "Werewolf",
Ability = "Kill",
Max = 3
},
Seer = {
Team = "Village",
Ability = "Peek",
Max = 1
},
Doctor = {
Team = "Village",
Ability = "Protect",
Max = 1
}
}
return Roles
i would like any help please!
the role value string, i want that to be the main thingy yaknow?
to control things, to check what role the player has, or to detect when it changes and it’ll be displayed on screen