local hasHoppa
local success, err = pcall(function()
hasHoppa = hoppadata:GetAsync(player.UserId)
end)
if success then
hoppa.Value = hasHoppa
else
hoppa.Value = false
end
if hoppa.Value == true then
snaphoppa:Clone().Parent = player:WaitForChild("Backpack")
end
hoppadata:SetAsync(player.UserId, hoppa.Value)
hoppa.Changed:connect(function()
print("Saving data...")
hoppadata:SetAsync(player.UserId, hoppa.Value)
print(player.UserId.."'s data has been saved!")
I’m trying to get it to reward you “Snap Hoppa”
when you have the bool set to true.
theres a lot of script unseen, but it doesen’t even give you the item
Have you print debugged it and checked the value was actually true? I’d also recommend try playing the game rather than testing it in Studio as bugs do occur frequently with DataStores in testing.
I’m going to test your script out later and see if I can get anything from that. I also suggest using print statements to find where your code stops.
Edit: In the script you provided player isn’t defined, maybe try defining player.
Well I can’t test your code out a ton as I’m also assuming you defined hoppa up in your code as well. I’m probably missing something but I don’t see anything wrong with your script.
Why are you calling a pcall for the DataStore if you’re not checking if the data actually saved? (Yes I know you do if success then but that’s unnecessary as if it doesn’t you can’t do anything about it unless you are storing everyone’s data to variables until the request queue becomes available again. Just saying that it’s slowing down the server to be doing that and complicates things more than they need to be.)
In this case you’re not telling where the tool is at. You’re only telling where it needs to go. So your script is just copying the root folder of the tool and cloning it to the client, which practically does nothing. That is why you’re script is not returning an error because it’s doing what you’re telling it to do.
Also I’ll be your console right quick
Variable “hoppa” is not defined.
Object “snaphoppa” does not exist or is not defined.
Unless there is more to the script that you haven’t posted, that’s the errors that I’m seeing, if your script is not returning an error, it means that you have defined the variable incorrect above the posted code snippet.
Don’t do separate datastores for single items, it’s very inefficient as one datastore limit can store 4mb. Just store data in a table then if your key in a table for hoppa returns nil then you know that the player doesn’t have hoppa.