How can i make a part invisible when a player gets a certain leaderstat

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
1 Like

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)


sorry i was doing something but ill try this now

hmm it doesnt seem to work

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)

You probably aren’t changing the value, which is the only time this will run. I would try this again, but try changing the player’s value.

I’m just referencing your post @soggyfeet13, sorry to ping you.