在 roblox studio 中可以点击接近提示但不执行任何操作

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

我有一个接近提示,当我按住“e”时,它应该显示一个店主并在聊天中打印你的等级和金钱,但它不会做类似的事情。当我按住“E”时,它什么也不做。 这是我的邻近部分的代码:

local Players = game:GetService("Players")

local shopMan = game.ReplicatedStorage.shopMan
local clonedShopMan = shopMan:Clone()
local username = Players.Name
local money = _G.publicPlayerSession.Money
local level = _G.publicPlayerSession.Level
local purchased = false

function loadData()
    
    if level == 1 then
        --new stand for free
    elseif level == 2 then
        --stand with another worker
    end
end

script.Parent.Triggered:Connect(function(player)
    print(money)
    print(level)
    if level > 0 then
        purchased = true
        loadData()
    else
        purchased = false
    end
    
    if purchased == false then
        if money >= 150 then
            money -= 150
            level += 1
            clonedShopMan.Parent = workspace.Stand
            script.Parent:Destroy()
        end
    end
end)

我尝试更改一些代码,例如从函数中删除播放器并尝试更改变量名称,但没有任何效果我得到了相同的结果

lua roblox
1个回答
0
投票

当表格内容改变时,变量不会动态更新。

© www.soinside.com 2019 - 2024. All rights reserved.