Check your output for any errors.
Theres been no type of errors.
Just plain with plugin errors.
Show me the leaderstats script.
Oh sorry, I misunderstood the question.
local Players = game:GetService("Players")
local function OnserverEvent(player)
local DataStoreService = game:GetService("DataStoreService")
local MyDataStore = DataStoreService:GetDataStore("MyDataStore")
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Strength = Instance.new("IntValue")
Strength.Name = "Strength"
Strength.Value = 0
Strength.Parent = leaderstats
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 0
Coins.Parent = leaderstats
local Data
local Success, errormessage = pcall(function()
Data = MyDataStore:GetAsync(player.UserId.."-Strength")
end)
if Success then
print("YAYY DATA STORE")
Strength.Value = Data
else
print("There was an error")
warn(errormessage)
end
end
Players.PlayerAdded:Connect(OnserverEvent)
game.Players.PlayerRemoving:Connect(function(Player)
local DataStoreService = game:GetService("DataStoreService")
local MyDataStore = DataStoreService:GetDataStore("MyDataStore")
local Success, errormessage = pcall(function()
MyDataStore:SetAsync(Player.UserId.."-Strength",Player.leaderstats.Strength.Value)
end)
if Success then
print("Player Data Sucessfully saved")
else
print("There was an error when saving data")
warn(errormessage)
end
end)
I donât really see why this wouldnât work, although I do see somethings you might want to fix in your script.
For example your not saving your coins and defining a service inside a loop which isnât really needed.
Is the coinâs CanCollide set to false? Because if so the .Touched event wonât work.
Hmmm thats werid⌠I canât see the issue
no, lol roblox studio weird lol.
You can try debugging your code.
local Coin = script.Parent
local Touched = false
print('Code: Running', Coin)
Coin.Touched:Connect(function(Hit)
if Touched then
return print('Part already touched.')
end
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
print(Player)
if Player then
print('Player found - Giving coins')
Touched = true
Player.leaderstats.Coins.Value += 1
Coin.Transparency = 1
wait(60)
Coin.Transparency = 0
Touched = false
end
end)
Just to be clear, what actually happens? Does the coin value increase/become transparent? Or does it do nothing at all?
leaderstats has an int value in it, i kinda dont understand what you mean but its fine.
I am trying to ask what actually happens when you touch the coin.
Look
18:19:05.897 Code: Running Coins - Server - Script:4
18:19:06.198 nil (x2) - Server - Script:12
This means that the coin (or player) doesnât exist, make sure the serverscript is inside the coin part.
is the coin touching the floor?
yeah but it still errors if i add an Local script i wondering why is it saying does not exist. I have screenshots and proof.
yes but we told the script to make sure its an humanoid/Player
It explains why it is printing nil though.