#Stars system , but no work on 100% only on 50%

46 messages · Page 1 of 1 (latest)

waxen stump
#

local player = game.Players.LocalPlayer

-- Čekání na StarsSystem
local starsSystem = player:WaitForChild("StarsSystem", 10)
if not starsSystem then
    warn("StarsSystem not found!")
    return
end

-- Čekání na Stars
local stars = starsSystem:WaitForChild("Stars", 10)
if not stars then
    warn("Stars not found in StarsSystem!")
    return
end

-- Čekání na StarsTimeSystem
local starsTimeSystem = player:WaitForChild("StarsTimeSystem", 10)
if not starsTimeSystem then
    warn("StarsTimeSystem not found!")
    return
end

-- Čekání na Star"x"Time
local starTimes = {
    starsTimeSystem:WaitForChild("Star1Time", 10),
    starsTimeSystem:WaitForChild("Star2Time", 10),
    starsTimeSystem:WaitForChild("Star3Time", 10),
    starsTimeSystem:WaitForChild("Star4Time", 10),
    starsTimeSystem:WaitForChild("Star5Time", 10),
}

local function updateStars()
    for i = 5, 1, -1 do
        if starTimes[i].Value <= 0 then
            stars.Value = math.max(stars.Value - 1, 0)
            break
        end
    end
end

for i = 1, 5 do
    starTimes[i].Changed:Connect(updateStars)
end

-- Odečítání od Star"x"Time každou sekundu
while false do
    wait(1)
    for i = 1, 5 do
        if starTimes[i].Value > 0 then
            starTimes[i].Value = starTimes[i].Value - 1
        end
    end
end
#
game:GetService("Workspace")["TESTOVACÍ VĚCI"].Skripty.StarTimeADD.Main.Part.ClickDetector.MouseClick:Connect(function(plr)
    print("fungjav")
    if plr.StarsSystem.Stars.Value == 1 then
        plr.StarsTimeSystem.Star1Time.Value += 1
        print(plr.StarsTimeSystem.Star1Time.Value)

    else if plr.StarsSystem.Stars.Value == 2 then
        plr.StarsTimeSystem.Star2Time.Value += 1
        print(plr.StarsTimeSystem.Star2Time.Value)

    else if plr.StarsSystem.Stars.Value == 3 then
        plr.StarsTimeSystem.Star3Time.Value += 1
        print(plr.StarsTimeSystem.Star3Time.Value)

    else if plr.StarsSystem.Stars.Value == 4 then
        plr.StarsTimeSystem.Star4Time.Value += 1
        print(plr.StarsTimeSystem.Star4Time.Value)

    else if plr.StarsSystem.Stars.Value == 5 then
        plr.StarsTimeSystem.Star5Time.Value += 1
        print(plr.StarsTimeSystem.Star5Time.Value)
    end
    end
    end
    end
    end
end)

game:GetService("Workspace")["TESTOVACÍ VĚCI"].Skripty.StarTimeADD.Main["-Part"].ClickDetector.MouseClick:Connect(function(plr)
    print("fungjav")
    if plr.StarsSystem.Stars.Value == 1 then
        plr.StarsTimeSystem.Star1Time.Value -= 1
        print(plr.StarsTimeSystem.Star1Time.Value)

    else if plr.StarsSystem.Stars.Value == 2 then
        plr.StarsTimeSystem.Star2Time.Value -= 1
        print(plr.StarsTimeSystem.Star2Time.Value)

    else if plr.StarsSystem.Stars.Value == 3 then
        plr.StarsTimeSystem.Star3Time.Value -= 1
        print(plr.StarsTimeSystem.Star3Time.Value)

    else if plr.StarsSystem.Stars.Value == 4 then
        plr.StarsTimeSystem.Star4Time.Value -= 1
        print(plr.StarsTimeSystem.Star4Time.Value)

    else if plr.StarsSystem.Stars.Value == 5 then
        plr.StarsTimeSystem.Star5Time.Value -= 1
        print(plr.StarsTimeSystem.Star5Time.Value)
    end
    end
    end
    end
    end
end)
#

game:GetService("Workspace")["TESTOVACÍ VĚCI"].Skripty.StarADD.Main.Part.ClickDetector.MouseClick:Connect(function(plr)

    plr.StarsSystem.Stars.Value += 1
    print(plr.StarsSystem.Stars.Value)
end)

game:GetService("Workspace")["TESTOVACÍ VĚCI"].Skripty.StarADD.Main["-Part"].ClickDetector.MouseClick:Connect(function(plr)

    plr.StarsSystem.Stars.Value -= 1
    print(plr.StarsSystem.Stars.Value)
end)
#
local DataStoreService = game:GetService("DataStoreService")

-- Nastavení scope na "Stars"
local scope = "Stars"
local PlayerStars = DataStoreService:GetDataStore("PlayerStars")

game.Players.PlayerAdded:Connect(function(player)
    local StarsSystem = Instance.new("Folder")
    StarsSystem.Name = "StarsSystem"
    StarsSystem.Parent = player

    local Stars = Instance.new("IntValue")
    Stars.Name = "Stars"
    Stars.Parent = StarsSystem

    -- Získání hvězd ze služby DataStore
    local success, currentStars = pcall(function()
        return PlayerStars:GetAsync(scope .. "_" .. player.UserId)
    end)

    if success and currentStars ~= nil then
        Stars.Value = currentStars
    else
        Stars.Value = 0
    end

    -- Cyklus pro kontrolu změny hodnoty hvězd
    local lastStarsValue = Stars.Value

    while true do
        task.wait(10)

        -- Pokud se hodnota hvězd změnila, aktualizuj ji
        if Stars.Value ~= lastStarsValue then
            local success, updatedValue = pcall(function()
                return PlayerStars:UpdateAsync(scope .. "_" .. player.UserId, function(oldValue)
                    return Stars.Value
                end)
            end)

            if success then
                lastStarsValue = Stars.Value
            else
                warn("Failed to update stars for player: " .. player.Name)
                warn("Error details: " .. tostring(updatedValue))
            end
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local success, updatedValue = pcall(function()
        return PlayerStars:SetAsync(scope .. "_" .. player.UserId, player.StarsSystem.Stars.Value)
    end)

    if not success then
        warn("Failed to save stars for player: " .. player.Name)
        warn("Error details: " .. tostring(updatedValue))
    end
end)
#

5.(1/2)

local DataStoreService = game:GetService("DataStoreService")

-- Nastavení scope na "Stars"
local scope = "StarsTime"

local PlayerStarTimeStores = {
    PlayerStar1Time = DataStoreService:GetDataStore("PlayerStar1Time"),
    PlayerStar2Time = DataStoreService:GetDataStore("PlayerStar2Time"),
    PlayerStar3Time = DataStoreService:GetDataStore("PlayerStar3Time"),
    PlayerStar4Time = DataStoreService:GetDataStore("PlayerStar4Time"),
    PlayerStar5Time = DataStoreService:GetDataStore("PlayerStar5Time"),
}

game.Players.PlayerAdded:Connect(function(player)
    local StarsTimeSystem = Instance.new("Folder")
    StarsTimeSystem.Name = "StarsTimeSystem"
    StarsTimeSystem.Parent = player

    local Star1Time = Instance.new("IntValue")
    Star1Time.Name = "Star1Time"
    Star1Time.Parent = StarsTimeSystem

    local Star2Time = Instance.new("IntValue")
    Star2Time.Name = "Star2Time"
    Star2Time.Parent = StarsTimeSystem

    local Star3Time = Instance.new("IntValue")
    Star3Time.Name = "Star3Time"
    Star3Time.Parent = StarsTimeSystem

    local Star4Time = Instance.new("IntValue")
    Star4Time.Name = "Star4Time"
    Star4Time.Parent = StarsTimeSystem

    local Star5Time = Instance.new("IntValue")
    Star5Time.Name = "Star5Time"
    Star5Time.Parent = StarsTimeSystem

    -- Načítání hvězd
    for i = 1, 5 do
        local success, currentStarTime = pcall(function()
            return PlayerStarTimeStores["PlayerStar" .. i .. "Time"]:GetAsync(scope .. "_" .. player.UserId)
        end)
        local starValue = success and currentStarTime or 0
        StarsTimeSystem["Star" .. i .. "Time"].Value = starValue
    end

    -- Cyklus pro kontrolu změny hodnoty hvězd
    local lastStarValues = {
        Star1Time.Value,
        Star2Time.Value,
        Star3Time.Value,
        Star4Time.Value,
        Star5Time.Value,
    }
    
end)


ember badge
#

whats this?

waxen stump
#
  1. (2/2)
game.Players.PlayerRemoving:Connect(function(player)
    -- Uložení všech hvězd při odchodu
    for i = 1, 5 do
        local success = pcall(function()
            return PlayerStarTimeStores["PlayerStar" .. i .. "Time"]:SetAsync(scope .. "_" .. player.UserId, player.StarsTimeSystem["Star" .. i .. "Time"].Value)
        end)

        if not success then
            warn("Failed to save star" .. i .. " for player: " .. player.Name)
        end
    end
end)
#

Please help

ember badge
#

dms

waxen stump
#

Please help

somber nimbus
#

why did i get pinged

waxen stump
#

It is not your primary but PLEASE pensivecowboy

somber nimbus
#

i mean i would help but all you did is send ALOT of code and didnt even tell what it is outputting and expect me to magically solve it

waxen stump
#

But you might find it useful

unique niche
#

I'm awake

#

hwuh

somber nimbus
#

also i cant even read the comments its in a diffrent language

unique niche
waxen stump
#

Loading Stars

quiet phoenixBOT
#

studio** You are now Level 7! **studio

waxen stump
#

One is for loading starrs (from database)

#

seconds is for adding/removing stars

#

third is for adding/removing starstime

#

fourth is for loading startime (from database)

#

fiveth is when Star1Time is 0 remove 1 Star

#

pensivecowboyI am making it 14 dayspensivecowboy

waxen stump
#

When I have stars and time get to 0 it will remove me 1 star (good)
but when I add 1 star, it will add me 2! No 1!

unique niche
#

also here's how your message would be grammatically correct

#

I want it so that when I have at least 1 star and the decay time reaches 0, and when I add one star it will bring me to 2, not 1.

waxen stump
#

😄

#

I want delete 1 star when starTime is 0

unique niche
#

stars -= 1

quiet phoenixBOT
#

studio** You are now Level 16! **studio

waxen stump
waxen stump
#

Solved

#

😉