client script
local event = game:GetService("ReplicatedStorage"):WaitForChild("openChest")
local chests = game.Workspace:WaitForChild("map"):WaitForChild("chests")
event.OnClientEvent:Connect(function(bool,ChestName)
print(bool)
if bool == true then
print("true",chests[ChestName])
chests[ChestName]:WaitForChild("ProximityPrompt").Enabled = true
for i,v in pairs(chests[ChestName]) do
if v:IsA("MeshPart") then
v.Transparency = 0
end
end
elseif bool == false then
print("false",chests[ChestName])
chests[ChestName]:WaitForChild("ProximityPrompt").Enabled = false
for i,v in pairs(chests[ChestName]) do
if v:IsA("MeshPart") then
v.Transparency = 1
end
end
end
end)
serverscript:
local pro = script.Parent:WaitForChild("ProximityPrompt")
local ds = game:GetService("DataStoreService")
local Data = ds:GetDataStore("Tryyyyyyyyyy")
script.Parent.ProximityPrompt.Enabled = true
local openEvent = game:GetService("ReplicatedStorage"):WaitForChild("openChest")
local COOLdown = 20
-- 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
openEvent:FireClient(plr,true,script.Parent.Name)
else
openEvent:FireClient(plr,false,script.Parent.Name)
repeat
task.wait(1)
local pipi = OsFunc(cooldown - os.time())
script.Parent.ProximityPrompt.ActionText = pipi
until cooldown <= os.time()
openEvent:FireClient(plr,true,script.Parent.Name)
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("Angelics").Value += tonumber(random)
script.Parent.TimeLeft.Value = os.time() - cooldown
Data:SetAsync(key, os.time() + COOLdown)
cooldown = Data:GetAsync(key) or 0
openEvent:FireClient(plr,false,script.Parent.Name)
repeat
task.wait(1)
local pipi = OsFunc(cooldown - os.time())
script.Parent.ProximityPrompt.ActionText = pipi
until cooldown <= os.time()
openEvent:FireClient(plr,true,script.Parent.Name)
end
end)
i dont know whats wrong with the scripts, the server script is in workspace inside a chest model and the local script is in serverscripts, i tried to change the location of the scripts but it still doesnt work.