0
我的目標是創建一個變量(_G.rownedB和_G.gownedB),每1秒增加_G.RPoints或_G.GPoints 1的點數,直到其中一個點數爲1200。不幸的是,它似乎沒有正常運行,而是完全沒有工作,啓動遊戲,並看到當我捕捉到這一點時,點gui文本(_G.News.Text)不起作用。我的錯誤是什麼?Roblox Lua:隨機錯誤?
-- Script by Dropdatderp
capturing = nil
_G.rownedB = false
_G.gownedB = false
neutral = true
function get_player(part)
for _, player in ipairs(game.Players:GetPlayers()) do
if part:IsDescendantOf(player.Character) then
return player
end
end
end
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h ~= nil then
if _G.gownedB or neutral == true then
capturing = true
_G.News.Text = "Raiders are taking Point B!"
wait(10)
_G.News.Text = "Raiders have taken Point B."
capturing = nil
_G.rownedB = true
_G.gownedB = false
neutral = false
end
elseif _G.rownedB or neutral == true then
local player = get_player(part)
if player:IsInGroup("901313") then
capturing = true
_G.News.Text = "Defenders are taking Point B!"
wait(10)
_G.News.Text = "Defenders have taken Point B."
capturing = nil
_G.rownedB = false
_G.gownedB = true
neutral = false
repeat
wait(1)
_G.RPoints = _G.RPoints + 1
until _G.RPoints or _G.GPoints == 1200
end
end
end
repeat
script.Parent.Touched:connect(get_player)
script.Parent.Touched:connect(onTouched)
until _G.GPoints == 1200 or _G.RPoints == 1200