i am making a game where you can change you character, but when i change my character this script doesnt work and i cant collect the leaves, i keep pressing e and it doesnt work
local pro = script.Parent:WaitForChild("ProximityPrompt")
local ds = game:GetService("DataStoreService")
local Data = ds:GetDataStore("Leaves1")
script.Parent.ProximityPrompt.Enabled = true
local COOLdown = 3600
-- 86400 --24 Hours
-- 43200 -- 12 Hours
-- 21600 -- 6 Hours
-- 10800 -- 3 Hours
-- 3600 -- 1 Hour
local function OsFunc(osTime)
local hour = math.floor(osTime/3600)
osTime = osTime - hour * 3600
local mins = math.floor(osTime/60)
osTime = osTime - mins * 60
local sec = osTime
local text = hour..":"..mins..":"..sec
return text
end
game.Players.PlayerAdded:Connect(function(plr)
local key = plr.UserId
local cooldown = Data:GetAsync(key) or 0
if cooldown <= os.time() then
script.Parent.Transparency = 0.05
script.Parent.Transparency = 0.05
script.Parent.ProximityPrompt.ActionText = "Pick up"
else
script.Parent.Transparency = 1
script.Parent.Transparency = 1
repeat
task.wait(1)
local pipi = OsFunc(cooldown - os.time())
script.Parent.ProximityPrompt.ActionText = pipi
until cooldown <= os.time()
script.Parent.Transparency = 0.05
script.Parent.Transparency = 0.05
end
end)
local kaki = false
pro.Triggered:Connect(function(plr)
local key = plr.UserId
local cooldown = Data:GetAsync(key) or 0
if cooldown <= os.time() then -- not on cooldown
local random = math.random(1,5)
plr:WaitForChild("Materials"):WaitForChild("Leaves").Value += tonumber(random)
script.Parent.Attachment.ParticleEmitter:Emit(5)
script.Parent.Parent.TimeLeft.Value = os.time() - cooldown
Data:SetAsync(key, os.time() + COOLdown)
cooldown = Data:GetAsync(key) or 0
script.Parent.Transparency = 1
script.Parent.Transparency = 1
repeat
task.wait(1)
local pipi = OsFunc(cooldown - os.time())
script.Parent.ProximityPrompt.ActionText = pipi
until cooldown <= os.time()
script.Parent.ProximityPrompt.ActionText = "Pick up"
script.Parent.Transparency = 0.05
script.Parent.Transparency = 0.05
end
end)```