I am getting the error “Attempt to index nil with blah blah blah” (It doesnt actually say blah blah blah but you get the point) And I know that means i’m trying to identify something that does not or is yet to exist, the problem is to make them exist I need them to exist. Its really weird so just look at this script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.GoldBought
local RemoteFunction = ReplicatedStorage.ShopRemoteFunction
Event.OnServerEvent:Connect(function(Player,HookType)
local Folder = Player:WaitForChild("leaderstats")
local IntValue = Folder:WaitForChild("Coins")
local DataManager = require(game:GetService("ReplicatedStorage").DataManager)
local data = DataManager:Get(Player)
local TPoseEquipped = data.TPoseEquipped
local TPoseOwned = data.TPoseOwned
local GoldenHookEquipped = data.GoldenHookEquipped
local GoldenHookOwned = data.GoldenHookOwned
RemoteFunction:InvokeClient(TPoseEquipped,TPoseOwned,GoldenHookEquipped,GoldenHookOwned)
if HookType == "GoldenHook" then
if GoldenHookOwned.Value == false then
if IntValue.Value >= 1 then
IntValue.Value = IntValue.Value - 1
GoldenHookOwned.Value = true
end
end
elseif HookType == "TPose" then
if TPoseOwned.Value == false then
if IntValue.Value >= 1 then
IntValue.Value = IntValue.Value - 1
TPoseOwned.Value = true
end
end
end
end)
Notice how I am trying to give a value to these things (TPose, GoldenHook, ect) but since they do not exist I can not reference them, I need you guys to help me. How do I reference/change their value. Also if it helps this is a profile service issue, and this is my data manager (My first EVER data manager so dont judge)
local Players = game:GetService("Players")
local ProfileService = require(script.Parent.ProfileService)
local ProfileStore = ProfileService.GetProfileStore(
"Player",
{
Coins = 0;
GoldenHookOwned = false;
GoldenHookEquipped = false;
TPoseOwned = false;
TPoseEquipped = false;
}
)
local Profiles = {}
local function onPlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync(
"Player_" .. player.UserId,
"ForceLoad"
)
if profile then
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick()
end)
if player:IsDescendantOf(Players) then
Profiles[player] = profile
else
profile:Release()
end
else
player:Kick()
end
end
local function onPlayerRemoving(player)
local profile = Profiles[player]
if profile then
profile:Release()
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)
local DataManager = {}
function DataManager:Get(player)
local profile = Profiles[player]
if profile then
return profile
end
end
return DataManager
For the love of everything Roblox please quit posting new threads about the same script!
The information on each thread is important and can help others understand your issue. If you keep posting new threads you’ll have to answer all those questions again.
Please be a little more patient. Usually you need to wait a few days for someone who can help you to read your post. Everyone here volunteers their time and efforts so they aren’t on 24/7.
Okay, sorry about that. Which one should I keep, and I’ll take the others down.
EDIT:
I am sorry about all the posts, some of them are very similar but I geuss I thought that they were just barley different enough to have different posts. Also for me its seems the older the post the more my problem is kinda ignored, for example a have 1 or 2 posts that are months old and still havent been answered (But I did trouble shoot them eventually) Again very sorry.
The “blah blah blah” may be the most important part of that error message. Please state the full error message and point out exactly which line of which script is causing the error so we can best help.
If you just need default values you could edit your datamanager to return one; though I do not know how this is supposed to act with the profile service script mentioned.
function DataManager:Get(player)
local profile = Profiles[player]
if profile then
return profile
else
-- give default
return {
Coins = 0,
GoldenHookOwned = false,
GoldenHookEquipped = false,
TPoseOwned = false,
TPoseEquipped = false,
}
end
end
Now a new error: attempt to index nil with ‘Changed’
But the only thing that has changed in it is the local script connected to it
local script:
RemoteFunction.OnClientInvoke = function(player,TPoseEquipped,TPoseOwned,GoldenHookEquipped,GoldenHookOwned)
GoldenHookOwned.Changed:Connect(function()
if GoldenHookOwned == true then
ShopFrame.SframeClip.SFrame.GHDecor.GHPrice.Text = "Owned"
end
end)
TPoseOwned.Changed:Connect(function()
if TPoseOwned == true then
ShopFrame.AframeClip.AFrame.TPDecor.TPPrice.Text = "Owned"
end
end)
end
btw this is only some of the script but I believe this is all you need to help me with this rabbit hole of errors.
So is there any way to detect if my table has changed? It does not have to be a specific thing in the table btw, just the table itself would work fine as well.
I dont know whats going on but I think I really screwed up when I made that profile service thing I while back. I finally fixed my original issue, but then I printed my data and no matter what I do it is always the default data. It is not updating at all. Nothing.
Also I fixed the first issue by just deleting the .changed thing because I did not need it at all.
I am SOOOOOO close, an I am learning so many cool things, and I am 78.29% confident I can handle my problems from now on… except one. How do I access server script service from a client side script?
EDIT:
Might be able to fix EVERYTHING (amazing ik) but I wont say this is issue is solved until im done trouble shooting everything.