#Sect/Guild System Improvement help
1 messages · Page 1 of 1 (latest)
local DTS = game:GetService("DataStoraService")
local GS = DTS:GetDataStore("GuildStorage")
local currentkey = "Beta"
local module = {}
local function getguilds()
local sucess , data = pcall(function()
return GS:GetAsync(currentkey)
end)
if not sucess then
print("fialed to get data deu to unknown errors")
return nil
return data
end
local function saveguilds(guildstosve)
local success,err = pcall(function()
GS:SetAsync(currentkey,guildstosave)
end)
if not success then
print("failed to save data"
end
end
function module:GetGuildName(guildid)
local guilds = getguilds()
if guilds[guildid] then
return guild[guildi]
end
function module:CreateGuild(guildid, Name, creator)
local guilds = getguilds()
for id, guild in pairs(guilds) do
if guild.Name == Name then
return false, "name is allready taken"
end
end
guilds[guildid] = {
Name = Name,
Members = {[creator.Id] = "Leader"},
RequestedMembers = {}, -- well be conenig players the leder reqested to join
}
saveguilds(guilds)
end
function module:AddMember(guildid, playerid, requesterid)
local guilds = getguilds()
if not guilds[guildid] then return false, "Guild not found" end
if guild.Members[requesterid] ~= "Leader" then return "does not have permission to add a player" end
for id, guild in pairs(guilds) do
if guild.Members[playerid] then
return false, "Player already in a guild"
end
end
guild.RequestedMembers[playerid] = "Member"
saveguilds(guilds)
end
function module:RemoveMember(guildid,playerid,requesterid)
local guilds = getguilds()
if not guilds[guildid] then return false, "Guild not found" end
if guild.Members[requesterid] ~= "Leader" then return "does not have permission to add a player" end
guild.RequestedMembers[playerid] = nil
saveguilds(guilds)
end
function module:DestroyGuild(guildid,requesterid)
local guilds = getguilds()
if not guilds[guildid] then return false, "Guild not found" end
guilds[guildid] = nil
saveguilds(guilds)
end
return module
first of all.
print("fialed to get data deu to unknown errors")
return nil
return data``` u forgot end
tf
let me
read it
i might be hight
local guilds = getguilds()
if not guilds[guildid] then return false, "Guild not found" end
guilds[guildid] = nil
saveguilds(guilds)
end``` wont do anything
@dusk sand
thats it...
holy
im saving so it saves and removes the guild
wont do anything
you're jst saving the guild back without any changes
guilds[guildid] = nil
...
ye
lol
told u im high
i tho something was wrong lol