You left the :GetPlayerFromCharacter() funciton blank. Try this instead:
local cooldown = false
local tool = game.ServerStorage.Pepsi
local debugvalue = 0
if debugvalue == 0 then
workspace.StandartPepsi.Touched:Connect(function(hit)
if cooldown == false and game.Players:GetPlayerFromCharacter(hit.Parent) then
cooldown = true
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
debugvalue = debugvalue + 1
local toolclone = tool:Clone()
toolclone.Parent = Player.Backpack
wait(0.1)
cooldown = false
end)
end
ServerScriptService i think lol
Huh, this works already lol, everything works
apoaddda:
local DataStoreService = game:GetService("DataStoreService")
local ServerStorage = game:GetService("ServerStorage")
local DataStore = DataStoreService:GetDataStore("ToolData")
local ToolName = "" -- Name of tool
local function OnPlayerAdded(player)
local Data
local success, err = pcall(function()
Data = DataStore:GetAsync(player.UserId.."-Data")
end)
if Data ~= nil then
if ServerStorage:FindFirstChild(Data) then
local Item = ServerStorage:FindFirstChild(Data)
Item:Clone().Parent = player.Backpack
end
else
print("New Player")
end
end
local function OnPlayerRemoving(player)
if player:FindFirstChild(ToolName) then
local Tool = player:FindFirstChild(ToolName)
local success, err = pcall(function()
DataStore:SetAsync(player.UserId.."-Data", Tool.Name)
end)
end
end
game.Players.PlayerAdded:Connect(OnPlayerAdded)
game.Players.PlayerRemoving:Connect(OnPlayerRemoving)
Hm don’t seems what this works, will it work in studio?
apoaddda
(apo)
August 28, 2021, 5:04pm
#45
Make sure studio api services are enabled.
what do you mean? the script that he posted didnt work mine should
It’s says me new player, even if i took tool
apoaddda
(apo)
August 28, 2021, 5:05pm
#48
Yes, it should say that the first time you join and then once you leave it will save the data.
1 Like
apoaddda:
n
Need to publish game then (30 letters)
His script is working ayoo, we are talking about saving tool now
Still says me new player, i launched game twice and took pepsi one time
apoaddda
(apo)
August 28, 2021, 5:07pm
#52
Ok, well I am sorry, I wont be able to answer until tomorrow, sorry.
Oh didn’t see that sorry. I only saw that he needed help with the tool cloning
K dm me message when you can help me, amma make other things rn, thank you
I just realized that the game deletes anything into serverstorage.
Lol yes this is right, it’s just hide them xd