Greetings,
the following issue includes two scripts.
The first script is a Server Script, which has the purpose of loading data from a Datastore and sending it via a Remote Event to a Local Script. Unfortunately the data, that the Local Script receives is printed as nil?
Server Script:
local CurrentSword = ReplicatedStorage:WaitForChild("CurrentSword")
local DatabaseModule = require(game:GetService("ServerScriptService"):WaitForChild("DatabaseModule"))
--#CURRENT SWORD#--
game.Players.PlayerAdded:Connect(function(Plr)
CurrentSword:FireClient(Plr, DatabaseModule.LoadPlayerData(Plr, "SwordDatabase"))
print(DatabaseModule.LoadPlayerData(Plr, "SwordDatabase"))
end)
Console Output:
https://i.gyazo.com/4c748ef95f1190fbcc5b2c9dd23bb47e.png
Local Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CurrentSelectedSword = ReplicatedStorage:FindFirstChild("CurrentSword")
CurrentSelectedSword.OnClientEvent:Connect(function(Sword)
local CurrentDataBaseSword = game:GetService("ServerStorage"):FindFirstChild(Sword)
print(CurrentDataBaseSword)
end)
Console Output:
https://i.gyazo.com/793b9629a16d7b0146705555f960d5e3.png
Issue:
As you can see the Data fired by the server does not get transmitted into the Local Script properly.
My attempts to fix:
I have tried using tostring() on this DatabaseModule.LoadPlayerData(Plr, "SwordDatabase") sadly that has not helped me at all.
Thank you for reading, I appreciate any help!