**I'm currently making a Simulator game with a special Kill Door system. Through killing monsters you will obtain kills from the leaderstats and if you reached the 100 kills the door will unlock and save itself. But i don't really know where i made the mistake
If i am in roblox studio the door will unlock and save itself, but in the client the door will also unlock if i reach the 100 kills, but when i rejoin the door isnt gone while i have 100 kills.
Another problem.. When a player in the client reached the 100 Kills, the door will not only unlock for him but also for everyone else in the client. How do i fix this problem **
--// Services
local Players = game:GetService("Players")
--// Variables
local door = game.Workspace.FirstDoor
--// Main Code
local function CheckKill(val) if val >= 100 then door:Destroy() else print("Not enough") end end
Players.PlayerAdded:Connect(function(Player) local leaderstats = Player:WaitForChild("leaderstats") local killStat = leaderstats:WaitForChild("Kills") CheckKill(killStat.Value) leaderstats.Kills.Changed:Connect(function(Value) CheckKill(Value) end) end)

1 comment
^^