Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua 期望Roblox Studio';}';(要在第5行结束';{';),则得到';游戏';_Lua_Roblox - Fatal编程技术网

Lua 期望Roblox Studio';}';(要在第5行结束';{';),则得到';游戏';

Lua 期望Roblox Studio';}';(要在第5行结束';{';),则得到';游戏';,lua,roblox,Lua,Roblox,我做了一个关于AlvinBlox的宠物蛋的教程,但它不起作用。我不断收到一个错误,说: 固定的: 18:34:03.253-ServerScriptService.PetModule:7:应为“}”(关闭 “{”在第5行),得到“游戏”18:34:03.255-请求的模块 加载时遇到错误 新问题: 19:26:49.473-ServerScriptService.PetModule:54:解析if语句时应为“then”,但得到“number” 以下是脚本: local petModule = {

我做了一个关于AlvinBlox的宠物蛋的教程,但它不起作用。我不断收到一个错误,说:

固定的:

18:34:03.253-ServerScriptService.PetModule:7:应为“}”(关闭 “{”在第5行),得到“游戏”18:34:03.255-请求的模块 加载时遇到错误

新问题: 19:26:49.473-ServerScriptService.PetModule:54:解析if语句时应为“then”,但得到“number”

以下是脚本:

local petModule = {}

petModule.pets = {
    
    ["Legendary"] = {
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Dominus Ultimus");
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Demonic Dominus");
    };
    
    ["Rare"] = {
    game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Forgotten kraken");
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Mythical Demon");
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Creature of light");
    };
    
    ["Uncommon"] = {
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Angel");
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Pumkin");
    game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Ninja");  
    };
    
    ["Common"] = {
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Dog");
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Cat");
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Fox");
        game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Panda");
    };
    
}

-- Weighted Selection o((>ω< ))o

petModule.rarities = {
    
    ["Legendary"] = 7.5; -- Change the Legendary,Rare,Uncommon and Common 
--   number to increase or decrease chance
    
    ["Rare"] = 15;
    
    ["Uncommon"] = 25;
    
    ["Common"] = 50;
    
}

petModule.chooseRandomPet = function()
    
    local randomNumber = math.random(1,100)
    
    local counter = 0
    
    for rarity, weight in pairs(petModule.rarities) do
        counter = counter + weight
        if Random number <= counter then --This is the problem
            
            local rarityTable = petModule.pets[rarity]
            local chosenPet = rarityTable[math.random(1,#rarityTable)]
            
            return chosenPet
            
        end
    end
    
end

return petModule
local petModule={}
petModule.pets={
[“传奇”]={
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“多米努斯终极”);
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“恶魔多米努斯”);
};
[“稀有”]={
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“被遗忘的海怪”);
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“神话恶魔”);
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“光之生物”);
};
[“不寻常”]={
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“天使”);
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“南瓜”);
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“忍者”);
};
[“普通”]={
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“狗”);
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“猫”);
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“狐狸”);
游戏。复制存储:WaitForChild(“宠物”):WaitForChild(“熊猫”);
};
}
--加权选择o(>ω<)o
petModule.rarities={
[“传奇”]=7.5;——改变传奇、稀有、不寻常和普通
--增加或减少机会的数量
[“稀有”]=15;
[“不寻常”]=25;
[“普通”]=50;
}
petModule.chooseRandomPet=函数()
局部随机数=数学随机数(1100)
本地计数器=0
对于稀有性,成对的重量(petModule.rarities)可以
计数器=计数器+重量

if Random number对于您的新问题,我看到您在if语句中键入的是Random number,而不是Random number。因此,它应该是这样的:“表构造函数中的if Random number元素之间需要逗号(或分号)。这很有效,但现在我遇到了一个新问题。
local Random number=math.Random(1100)
,如果是随机数,则后跟