local DataStore = game:GetService("DataStoreService"):GetDataStore("ByteBank")
local Player = game.Players:GetPlayerFromCharacter(Player)
script.Parent.Touched:connect(function(Hit)
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if (Humanoid ~= nil) then
local ByteSpace = "user_" .. Player.userId
local ByteIndex = {}
if os.difftime(os.time, ByteIndex[1]) >= 21600 then
DataStore:UpdateAsync(ByteSpace, ByteIndex)
ByteIndex[1] = os.time()
ByteIndex[2] = ByteIndex[2] + 2
Player.PlayerGui.ByteCount.Amount = Player.PlayerGui.ByteCount.Amount + 2
end
end
end)
✓ ANSWER ACCEPTED
Can anyone help? Line 7 contains the error.
2 answers
✓ Accepted answer
This line is grabbing a non existent value
local Player = game.Players:GetPlayerFromCharacter(Player)
You need to actually define the character, as in
Example:
local Player = game.Players:GetPlayerFromCharacter(game.Workspace['Player1'])
Player is nil do
local Player = game.Players.LocalPlayer --make sure it's in a local script not a regular.
:GetPlayerFromCharacter() is used for getting the Character from the Player.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
It would be more helpful if you said what the error was