Roblox Studio:如果然后出错,则尝试所有操作

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

我不知道出什么问题了,它不断重复以下错误:Issue

local clicker = script.Parent.ClickDetector
local canclick = true

local chance = math.random(1,3)
if chance == 1 then 
clicker.MouseClick:connect(function(Player)
    if canclick then
        if Player:FindFirstChild("Stand").Value == "The World" then
            Player:FindFirstChild("Stand").Value = "Nightmare World"
            canclick = true
            Player:LoadCharacter()
            script.Parent:Remove()  
        else
    clicker.MouseClick:connect(function(Player)
    if canclick then
            Player:FindFirstChild("Stand").Value = "None"
            canclick = true
            Player:LoadCharacter()
            script.Parent:Remove()          
        end
    end
end)

我已经尝试过放个头,然后替换个头,甚至加上括号,但是没有任何效果。如果您能以某种方式重写代码或为我提供帮助,将不胜感激。

lua game-engine roblox
1个回答
1
投票
local clicker = script.Parent.ClickDetector
local canclick = true

local chance = math.random(1,3)
if chance == 1 then 
clicker.MouseClick:connect(function(Player)
    if canclick then
        if Player:FindFirstChild("Stand").Value == "The World" then
            Player:FindFirstChild("Stand").Value = "Nightmare World"
            canclick = true
            Player:LoadCharacter()
            script.Parent:Remove()  
        else
            clicker.MouseClick:connect(function(Player)
                if canclick then
                    Player:FindFirstChild("Stand").Value = "None"
                    canclick = true
                    Player:LoadCharacter()
                    script.Parent:Remove()    
                end
            end) -- here
        end
    end
end)

您忘记了右括号和结束语!我在评论中强调了它。 :)我没有测试它,但是如果它不起作用,我将再次检查它。

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