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.
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
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.
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.
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
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
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.
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