【发布时间】:2018-01-07 19:51:39
【问题描述】:
错误:
16:16:03.496 - Workspace.Storeroom.Pile of Crates.Wood Crate.Script:17:尝试索引字段“父”(零值)
脚本:
local db = true
local clickdetector = script.Parent:WaitForChild('ClickDetector')
clickdetector.MouseClick:Connect(function(plr)
local randomizer = math.random(1,6)
if randomizer == 1 or 2 or 3 then
script.Parent:Destroy()
local gift = game:GetService("ReplicatedStorage"):WaitForChild("Blue Keycard")
if db == true then
db = false
gift:Clone().Parent = plr.Backpack
wait(1)
db = true
end
end
if randomizer == 4 or 5 then
script.Parent:Destroy()
local gift = game:GetService("ReplicatedStorage"):WaitForChild("Red Keycard")
if db == true then
db = false
gift:Clone().Parent = plr.Backpack
wait(1)
db = true
end
end
if randomizer == 6 then
script.Parent:Destroy()
local gift = game:GetService("ReplicatedStorage"):WaitForChild("Green Keycard")
if db == true then
db = false
gift:Clone().Parent = plr.Backpack
wait(1)
db = true
end
end
end)
【问题讨论】: