I once again am making a new game but there is once again another issue, the doorways to new areas keep letting me through without taking any gems, so i need some help here is my script is there a way to fix it? and how?
local DSS = game:GetService("DataStoreService")
local Storage = DSS:GetDataStore("Score")
local Door = script.Parent
local debounce = true
game:GetService("Players").PlayerAdded:Connect(function(player)
local bool = Instance.new("BoolValue")
bool.Name = "RemoveDoor1"
bool.Value = false
bool.Parent = player
local success, result = pcall(function()
Storage:GetAsync(player.UserId)
end)
if not success then
warn(result)
else
local LoadValue = Storage:GetAsync(player.UserId)
if LoadValue then
bool.Value = LoadValue
print(bool.Value)
end
end
end)
game:GetService("Players").PlayerRemoving:Connect(function(player)
Storage:SetAsync(player.UserId, player:WaitForChild("RemoveDoor1").Value)
end)
Door.Touched:Connect(function(hit)
if debounce == false then return end
debounce = false
print("Door Hit")
local human = hit.Parent:FindFirstChild("Humanoid")
if human ~= nil then
print("Human touched door")
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
local sp = player:WaitForChild("leaderstats"):WaitForChild("GEMS")
local check = player:WaitForChild("RemoveDoor1")
if check.Value == false and sp.Value >= 250 then
print("Human passed test")
check.Value = true
sp.Value = sp.Value - 250
Door.CanCollide = false
wait(0.129)
Door.CanCollide = true
elseif check.Value == true then
print("Human already has access")
Door.CanCollide = false
wait(0.129)
Door.CanCollide = true
end
end
end
debounce = true
end)
(idk how it keeps breaking)

1 comment
Are you sure you haven't touched it before you test? Like, it is made so you can get through without giving gems when you have already given them before. (I don't think you are stupid, just sometimes people forget that) Any errors?