So basically I want to make a nuke, where only 2 players can have the nuke keys at the same time, for that I am using a module script to count how many keys have been picked up, now the issue is, that it yields infinite for no reason:
ModuleScript (ibmkey):
local keys = { keys = 0 }
return keys
The Script responsible for giving out keys:
local detector = script.Parent.ClickDetector
local serverstorage = game:WaitForChild("ServerStorage")
detector.MouseClick:Connect(function(x)
local imbkey = game.ServerScriptService:WaitForChild("ibmkey")
local ibmkeys = imbkey:WaitForChild("keys")
local launchkey = serverstorage:WaitForChild("IBM Launch Key"):Clone()
if ibmkeys == 2 then
return
end
launchkey.Parent = x.Backpack
end)
Output:
15:47:36.907 Infinite yield possible on 'ServerScriptService.ibmkey:WaitForChild("keys")' - Studio
15:47:36.907 Stack Begin - Studio
15:47:36.908 Script 'Workspace.TestingParts.Part.Script', Line 6 - Studio - Script:6
15:47:36.908 Stack End - Studio
15:47:48.130 Disconnect from ::ffff:127.0.0.1|58706 - Studio