I’m still quite new with scripting so please excuse me if this is a really stupid mistake
But basically my claiming system that should save to the game won’t work at all (like nothing about it works), but no errors are showing up.
local MarketplaceService = game:GetService("MarketplaceService")
local ClickDetector = script.Parent.Parent.ClickDetector
local DataStoreService = game:GetService("DataStoreService")
local OwnerData = DataStoreService:GetDataStore(script.Parent.Parent.Name)
local clone = game.ServerStorage.SignText:Clone()
local debouce = false
clone.Parent = game.StarterGui
clone.Adornee = script.Parent
clone.Name = script.Parent.Name
local data = Instance.new("Folder")
data.Name = "data"
data.Parent = workspace
local Owner = Instance.new("IntValue")
Owner.Name = script.Parent.Parent.Name
Owner.Value = 0
Owner.Parent = data
if OwnerData:GetAsync("StatueOwners") == 0 then
print(script.Parent.Parent.Name.." is unclaimed!")
else
wait()
local text = game.StarterGui:FindFirstChild(script.Parent.Name)
local id = game:WaitForChild("data"):WaitForChild(script.Parent.Parent.Name).Value
local username = game:GetService("Players"):GetNameFromUserIdAsync(tonumber(id))
text.Text = username
end
ClickDetector.MouseClick:Connect(function(Player)
local ownerdata = game.Workspace:FindFirstChild("data"):FindFirstChild(script.Parent.Parent.Name)
local text = game.StarterGui:FindFirstChild(script.Parent.Name)
if OwnerData:GetAsync("StatueOwners") == 0 then
text.Text = Player
script.Parent.Name = Player
ownerdata.Value = Player.UserId
wait(1)
OwnerData:SetAsync("StatueOwners", ownerdata.Value)
end
end)
Where does it break? Add prints pretty much everywhere and look for when a print is not printed. If everything prints, change what they print. Make them print whatever information is relevant.
This will help you find the source of the issue. Let me know once you know where the issue begins!
It’s supposed to have a value of 0 until first clicked, in which it should change the value to the userid of the person that clicked it — so if it’s never been clicked, it shouldn’t be trying to load anything because of the if OwnerData:GetAsync("StatueOwners") == 0 then right?
It went to else because the current owner isn’t 0, try printing what it is. I would guess it currently is nil. Are you certain that the children exist?
I thought that’s where you made a key? I was trying to look around last night about saving data to the game rather than to a user and all I could really find was not using their userid as the key and using something like that, but I’m not good at all with this sort of stuff so I probably didn’t understand it right
OKAY so I just noticed that it’s game: and not game.Workspace: — I fixed that but it’s still going to else. I also printed the value and it’s printing as 0. But now it’s at least giving some error for it
Ohh okay I changed all the others to check the value in the game and changed the if OwnerData:GetAsync("StatueOwners") == 0 then to if OwnerData:GetAsync("StatueOwners") > 0 then and it seems to be working now! Thank you so much