Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Won't fire the event, and why?

Asked by 9 years ago

I have a script

MysteryObjects = 0
local items = {"Mysterious Red Rod", "Mysterious Blue Orb", "Mysterious Gold Plate"}

script.Parent.Touched:connect(function(Toucher)
if Toucher.Parent and Toucher.Parent:FindFirstChild("Humanoid") then
Player = game.Players:GetPlayerFromCharacter(Toucher.Parent)
local HasItems = {}
local MysteriousObjects=0
for c,v in pairs(items) do
if Player.Backpack:FindFirstChild(v) and not HasItems[v] then
HasItems[v]= true
MysteriousObjects = MysteriousObjects+1
Player.Backpack:FindFirstChild(v):Destroy()
if v:match("Rod") then
script.Parent.Parent.Rod.Transparency = 0
print('Rod Placed')
elseif v:match("Orb") then
script.Parent.Parent.Orb.Transparency = 0
print('Orb Placed')
elseif v:match("Plate") then
script.Parent.Parent.Plate.Transparency = 0
print('Plate Placed')
end
end 
end


if MysteriousObjects==3 then
print('Staff Built')
wait(15)
game.Workspace["Midnight Moon Shrine"].Beam:Fire()
end
end
end)

Everything works fine, besides the fact you can't be holding the item, and them ore important fact, the last part won't work. It never fires the event nor prints it. Is there something wrong with the way i'm adding?

0
What type of object is `Beam`? Also, be careful -- This will only work if you deposit all three items at once -- I'm not sure if that's your intention or not. (If it's not, just move the declarations for `MysteriousObjects` and `HasItems` to be before the touched function) BlueTaslem 18071 — 9y

Answer this question