I wanted to make a lock to put on a level but once you beat the first level and get a certain leaderstat value the lock will become invisible and cancollide of how can I do this
I made this script but it doesn’t work no error either
local LevelLock = script.Parent
local priceToEnter = 1
if player.leaderstats.keys.Value >= priceToEnter then
LevelLock.Transparency = 1
end
Youre actually only checking the value once so when the value changes nothing will happen
local LevelLock = script.Parent
local priceToEnter = 1
player.leaderstats.keys.Changed:Connect(function()
if player.leaderstats.keys.Value >= priceToEnter then
LevelLock.Transparency = 1
LevelLock.CanCollide = false
end
end)
i did have this other script that makes the lock dissapear when you touch a part
also the part dissapears if you have a certain leaderstat but you do have to touch the part for it to dissapear
local door = script.Parent
local LevelLock = game.Workspace.LevelLock3
local priceToEnter = 3
door.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChildWhichIsA("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.leaderstats.keys.Value >= priceToEnter then
door.CanCollide = false
LevelLock.Transparency = 1
end
end
end)