尝试为 ROBLOX 游戏创建销售区域
Trying to Make a Sell Area for a ROBLOX Game
我正在尝试为我的 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时,你需要明确设置它们的值属性。
-- 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
我正在尝试为我的 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时,你需要明确设置它们的值属性。
-- 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