I’m making a coin service with knit and I’m having trouble with the client communicating with the server.
Service (Server):
local Knit = require(game:GetService("ReplicatedStorage").Packages.Knit)
local Players = game:GetService("Players")
local CoinService = Knit.CreateService {
Data = {},
Name = "CoinService";
Client = {};
}
function CoinService:Get(player: Player)
return CoinService.Data[player]
end
function CoinService:Add(player: Player, Amount: number)
CoinService.Data[player] += tonumber(Amount) or 0
end
function CoinService:Remove(player: Player, Amount: number)
CoinService.Data[player] -= tonumber(Amount) or 0
end
function CoinService.Client:GetCoins(player: Player)
return CoinService.Data[player]
end
function CoinService:KnitStart()
for i, v in pairs(Players:GetPlayers()) do
CoinService.Data[v] = math.random(1, 500)
end
Players.PlayerAdded:Connect(function(player)
CoinService.Data[player] = math.random(1, 500)
end)
Players.PlayerRemoving:Connect(function(player)
CoinService.Data[player] = nil
end)
end
function CoinService:KnitInit()
end
return CoinService
Controller(Client):
local Knit = require(game:GetService("ReplicatedStorage").Packages.Knit)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Coins = Knit.CreateController {
Name = "Coins";
}
function Coins:KnitStart()
local CoinService = Knit.GetService("CoinService")
local PlayerCoins = CoinService:GetCoins()
print(PlayerCoins)
end
function Coins:KnitInit()
end
return Coins
It doesn’t print the players coins, it prints “Promise(Started)”
I tried printing the players coins in the CoinService.Client:GetCoins() function and it works, but it doesn’t send the value to the client?