I cant really find any potential errors in this script, I did some digging on this topic and found a similar post. Also i just got a random like by Quenty ;-------;
The Module script isnāt called Player_Data
ā¦?
@UnknownName_0 , is the module named Player_Data?
Yes it does. (number character ignore)
i think the error is where it says local server = serverScriptService.Server try change that to local server = game.ServerScriptSevice.Server and with the local serverModules = server.Modules Instead put local serverModules = game.ServerScriptServer.Server.Modules
The issue in your script is where you try to add the function PlayerAdded to playerData, which canāt have functions added to it. Are you trying to have PlayerAdded run whenever a player joins? If so, re-write that function to look like this.
local function PlayerAdded(player)
local clonedData = playerData:Clone()
clonedData.Parent = player
end
game.Players.PlayerAdded:Connect(PlayerAdded)
local serverScriptService = game:GetService("ServerScriptService")
local server = serverScriptService:WaitForChild("Server")
local serverModules = server:WaitForChild("Modules")
local PlayerData = require(serverModules:WaitForChild("ModuleScript"))
First script you posted.
local players = game:GetService("Players")
local serverStorage = game:GetService("ServerStorage")
local playerData = serverStorage:WaitForChild("Player_Data")
local clonedData
local module = {}
module.PlayerAdded = players.PlayerAdded:Connect(function(player)
clonedData = playerData:Clone()
clonedData.Parent = player
end)
module.PlayerRemoving = players.PlayerRemoving:Connect(function(player)
clonedData.Parent = serverStorage
end)
return module
Second script you posted.