【发布时间】:2021-07-04 00:04:44
【问题描述】:
当我在 Roblox Studio 中时,我正在制作一个与您之前的脚本类似的脚本:
local amount = 123
local Module = require(game.ServerScriptService:WaitForChild("Module"))
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.leaderstats.Currency.Value >= amount then
player.leaderstats.Currency.Value = player.leaderstats.Currency.Value - amount
local pet = Module.chooseRandomPet()
--> print(pet.Name.." selected") <--
end
end)
当我去使用它时,我在箭头区域周围看到“尝试将 nil 与字符串连接起来”。
我会做些什么来解决这个障碍。
【问题讨论】:
-
您应该分享来自
Module.chooseRandomPet()的代码,因为无论它在做什么,它都不会归还宠物。 -
@Kylaaa 可能是宠物,但没有
Name字段。 -
print((pet.Name or "no pet").." selected")