Attempt to index number with ' Name ' [Repost]

Provide an overview of:* What does the code do and what are you not satisfied with?The code is supose to add Exp to but is say’s that attempt to index with ’ Name ', probrably i need remove a .Name in somewhere but i dont know where, the code basically add Exp to data Exp Player.

DataOfPlayer = DataStore:WaitForChild("BlindFunction"):Invoke("GetData", Player)
DataStore:WaitForChild("BlindFunction"):Invoke("ChangeData", Player, "EtcMasteryExp", DataOfPlayer["EtcMasteryExp"] + (math.random(1, 10)))

here is the OnInvoke Script

script.Parent.DataStore.BlindFunction.OnInvoke = function(what, arg1, arg2, arg3)
print("Get Invoked for "..what.." information.")
if what == "ChangeData" then
BlindFunction(arg1, arg2, arg3)
elseif what == "GetData" then
return dataFolder[arg1.Name]
end

return nil
end

Thanks.

1 Like

Please help me some one, i dont know what to do ;9

It could be because the what parameter is automatically set to the player, followed by arg1 being set to GetData or ChangeData, and arg2 is the player again, although not necessary since what is already the player.

When invoking the server, the first param will automatically be set to the player invoking the event, then your custom arguments will be provided after the player.

1 Like

Could you provide more context/code for where you’re calling the BindableFunction at? The issue is likely where you’re invoking BlindFunction at. If I had to guess, Player is nil.

1 Like

here is when call the changedata

function changeValue(player, valueName, value)
	
	if dataFolder[player.Name][value.Name] then
		dataFolder[player.Name][valueName] = value
	end
	
	checkMastery(player)
	
	remote:FireClient(player, "GiveData", dataFolder[player.Name])
	
end
1 Like

i make a mistake here is it the work change, but nothing still happening

script.Parent.DataStore.BlindFunction.OnInvoke = function(what, arg1, arg2, arg3)
print("Get Invoked for "..what.." information.")
if what == "ChangeData" then
changeValue(arg1, arg2, arg3)
elseif what == "GetData" then
return dataFolder[arg1.Name]
end

return nil
end

Could you please provide the line of the error which is shown in the output?

oh hey there sorry, so the second line is where the error is

DataOfPlayer = DataStore:WaitForChild("BlindFunction"):Invoke("GetData", Player)
DataStore:WaitForChild("BlindFunction"):Invoke("ChangeData", Player, "EtcMasteryExp", DataOfPlayer["EtcMasteryExp"] + (math.random(1, 10)))```

Can you show us what Player is (above the error)?

how i show that, idk how do i need show the line of the error

Please show us further information of the script, including the “Player” variable. This will help us find out what type of value you’re using.

ok so here is

local dataStore = game:GetService("DataStoreService"):GetDataStore("DataStore")
local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteServer"):WaitForChild("Data"):WaitForChild("DataRemote")
local dataFolder = {}

local defaultData = {
	
	["EtcMastery"] = 1,
	["EtcMasteryExp"] = 0,
	["EtcMasteryExpNeeded"] = 10
	
}

function checkMastery(player)
	if dataFolder[player.Name]["EtcMasteryExp"] >= dataFolder[player.Name]["EtcMasteryExpNeeded"] then
		dataFolder[player.Name]["EtcMasteryExp"] = 0
		dataFolder[player.Name]["EtcMasteryExpNeeded"] = dataFolder[player.Name]["EtcMasteryExp"] + math.random(150, 350)
		dataFolder[player.Name]["EtcMastery"] = dataFolder[player.Name]["EtcMastery"] + 1
		remote:FireClient(player, "GiveData", dataFolder[player.Name])
	end
end
DataOfPlayer = DataStore:WaitForChild("BlindFunction"):Invoke("GetData")
DataStore:WaitForChild("BlindFunction"):Invoke("ChangeData", "EtcMasteryExp", DataOfPlayer["EtcMasteryExp"] + (math.random(1, 10)))
script.Parent.DataStore.BlindFunction.OnInvoke = function(arg1, what, arg2, arg3)
print("Get Invoked for "..what.." information.")
if what == "ChangeData" then
BlindFunction(arg1, arg2, arg3)
elseif what == "GetData" then
return dataFolder[arg1.Name]
end

return nil
end

Check if this works. It implements my previous reply.

I do not think this will work. I understand that the first parameter is automatically set to the player, but it only happens on RemoteFunctions/Events and not BindableFunctions. I tested this earlier.

This is a blind function, not necessarily a bindable function. This means he could be using RemoteFunctions.

If he was using RemoteFunctions, it would be “OnServerInvoke” or “OnClientInvoke”. In this case, it is “OnInvoke” which indicates that it is a bindable function. I am sorry if I am incorrect.

Is it because in this if statement you are calling value.Name instead of using the valueName parameter? Here is the fixed code:

function changeValue(player, valueName, value)
	
	if dataFolder[player.Name][valueName] then
		dataFolder[player.Name][valueName].Value = value
	end
	
	checkMastery(player)
	
	remote:FireClient(player, "GiveData", dataFolder[player.Name])
	
end

I’ve noticed that roblox shows multiple lines if you’re invoking or using functions and that is why I’m confused.

In my opinion, I don’t think the line you provided is the one with the error which indicates that it’s somewhere inside the bindablefunction.

Maybe send a screenshot of the output. This way, we can see all the lines.

but value.Name isint the name of the value

i use value.Name for set the valueName variable