【发布时间】:2020-02-16 23:35:03
【问题描述】:
我在 Roblox 中制作了杀戮脚本的现金,但想更进一步并实现一个脚本,当玩家拥有游戏通行证时,该玩家将获得比其他普通玩家更多的现金。
这是 Roblox 中一款大逃杀风格的游戏,当我进行游戏测试时,没有错误,但脚本无法运行。
game.Players.PlayerAdded:connect(function(player)
local folder = Instance.new("Folder",player)
folder.Name = "leaderstats"
local currency1 = Instance.new("IntValue",folder)
currency1.Name = "Cash"
local increment = 50
if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,7382818)then
increment = increment + 50
end
player:WaitForChild("Humanoid").Died:connect(function()
local tag = player.Humanoid:FindFirstChild("creator")
if tag ~= nil then
local killer = tag.Value
if killer ~= nil then
-- Find the killer's leaderstats folder
local killerStats = killer:FindFirstChild("leaderstats")
if killerStats ~= nil then
-- Find the killer's Cash IntValue
local killerCash = killerStats:FindFirstChild("Cash")
-- Increase cash as before
killerCash.Value = killerCash.Value + increment
end
end
end
end)
我预计拥有游戏通行证的 VIP 玩家会收到更多现金,但当我测试它时,根本没有玩家因杀死其他玩家而收到任何现金。
【问题讨论】:
-
你没有关闭外部(或内部)函数
-
你用
end)关闭player:WaitForChild("Humanoid").Died:connect(function(),但你没有用end)关闭game.Players.PlayerAdded:connect(function(player)