制作一个数据存储来保存对象的状态

问题描述 投票:0回答:0

我在编程的 gui 中做了一个本地脚本,这样当我触摸一个方块时,gui 就会出现,并且该方块被破坏到 gui 不会再次出现,但我希望即使我离开游戏并再次进入,该方块也会保持破坏状态

我试过几次数据存储,但都没有用,每次我重置游戏时,方块都回来了

我的本地文字

startergui -> screengui

方言:

local frame = script.Parent.Frame
local text = script.Parent.Frame.TextLabel
local block = workspace:WaitForChild("Chest")
local sound = script.Sound
block.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player and player == game.Players.LocalPlayer then
        sound:Play()
    block:Destroy()
    wait()
for i = 1,10 do
    text.TextTransparency -= 0.1
    text.BackgroundTransparency -= 0.1
    frame.Transparency -= 0.1
    wait(0.01)
end
wait(5)
for i = 1,10 do
    text.TextTransparency += 0.1
    text.BackgroundTransparency += 0.1
    frame.Transparency += 0.1
    wait(0.01)
end
    end
    end)


datastore data-storage
© www.soinside.com 2019 - 2024. All rights reserved.