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

Knit Module Error: Infinite yield possible on ReplicatedStorage.Knit:WaitForChild(“Services”)?

Asked by 3 years ago

I’m trying to use Knit for a commission. When I try to run the game, the Knit Client module returns this error.

 14:08:58.907  Infinite yield possible on 
'ReplicatedStorage.Knit:WaitForChild("Services")'  -  Studio
14:08:58.907  Stack Begin  -  Studio
14:08:58.907  Script 'ReplicatedStorage.Knit.KnitClient', Line 30  -  
Studio - KnitClient:30
14:08:58.908  Stack End  -  Studio

It won’t run my script at all because of this error. I’ve tried removing Knit and putting it back in again. The Knit module is in ReplicatedStorage exactly as it is noted in the API.

1 answer

Log in to vote
0
Answered by
TGazza 1336 Moderation Voter
3 years ago
Edited 3 years ago

Little example on how to call Knit correctly I'm new to this Module, but I found the API on how to use it.

You can find the Instruction manual here:

https://sleitnick.github.io/Knit/gettingstarted/

Example:

local RS = game:GetService("ReplicatedStorage")
--// allways add a time out on your WaitForChild functions! (Note: the 10 here is 10 secs!)
local KnitObj = RS:WaitForChild("Knit",10)
local Knit = require(KnitObj)
local someDataStore = game:GetService("DataStoreService")

-- Create the service:
local MoneyService = Knit.CreateService {
    Name = "MoneyService";
}

-- Add some methods to the service:

function MoneyService:GetMoney(player)
    -- Do some sort of data fetch
    local money = someDataStore:GetAsync("money")
    return money
end

function MoneyService:GiveMoney(player, amount)
    -- Do some sort of data fetch
    local money = self:GetMoney(player)
    money += amount
    someDataStore:SetAsync("money", money)
end

Knit.Start():Catch(warn)

local Services = Knit.Services

print(Services)

if this script still doesn't work then it might be worth downloading a fresh copy of the Module Linkies:

Roblox Link to Module:

https://www.roblox.com/library/5530714855/Knit

GitHub Link to Module (Might be newer!): https://github.com/Sleitnick/Knit/releases/latest/download/knit.zip

hope this helps! :)

Ad

Answer this question