I sometimes get an error when playing on the server (about 6 out of 10 times). However, I never get this error when using Roblox Studio (0 out of 10 times). I don’t know what is causing this error.
it’s so weird the object literally exists in the player character, I assign it to starterplayercharacter , and you can see it on the screenshot, the Data folder exists, I even use injector and open explorer to make sure the folder is exist
I apologize for not providing a script, it’s a simple script that read variable data, since I initialize the variable on startercharacter I don’t think I should provide the script, but if you want to know the script here is the script that I use to read the variable
local character = player.Character or player.CharacterAdded:Wait()
repeat
task.wait(0.6666)
until character ~= nil
local mousebool = character.Data.Mouse
after I modify it to
local mousebool = character:WaitForChild("Data").Mouse
I got error
attempt to index nil with WaitForChild
the thing that keeps bothering me is this error sometimes appear sometimes gone when on actual server
Instead of putting the data folder in StarterCharacter, try putting it in ServerStorage and make a server script where it replicates the data folder onto the player when CharacterAdded fires like so:
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local Data = ServerStorage:WaitForChild("Data")
Players.PlayerAdded:Connect(function(Plr)
Plr.CharacterAdded:Connect(function(Char)
local DataClone = Data:Clone()
DataClone.Parent = Char
end)
end)
correct, I just check that the error comes from another script that has the same name,
I didn’t realize that I have fix this code
local mousebool = character:WaitForChild(“Data”).Mouse
I initially thought that the error was still coming from the first script, but I later realized that it was actually caused by this code.
local somevalue = character.Stats.Data.somevalue
On a real server, it seems to take longer to load the child inside the startercharacter compared to on Roblox Studio, I fix it by using WaitForChild for both Stats and folder