试图为ROBLOX游戏建立销售区域



我正试图为我的大厅制作一个ROBLOX游戏的销售区。

然而,每当我踏上销售区域(有积分(时,我似乎没有得到任何现金,我的积分也不会改变。

请帮忙?

这是我的代码:

local sellPart = script.Parent
game.Players.PlayerAdded:Connect(function(plr)
sellPart.Touched:Connect(function(hit)
local hrp = hit.Parent:FindFirstChild("HumanoidRootPart")
if hrp then
local player = game.Players:GetPlayerFromCharacter(hrp.Parent)

local zombpoints = player.leaderstats.Zombpoints
local zombcash = player.leaderstats.Zombcash

zombcash = zombpoints
zombpoints = 0
end
end)
end)

希望这能有所帮助。

在代码中,将NumberValue对象存储到变量中,然后覆盖这些变量。您没有修改存储在变量中的数据。

因此,当您使用NumberValues时,您需要显式设置它们的Value属性。

-- get the point values out of the leaderstats
local zombpoints = player.leaderstats.Zombpoints
local zombcash = player.leaderstats.Zombcash
-- convert the points to cash and add it to cash pile
zombcash.Value = zomcash.Value + zombpoints.Value
-- reset the point counter
zombpoints.Value = 0

最新更新