Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script внутри детали-переключателя / двери / зоны
- local Players = game:GetService("Players")
- local part = script.Parent
- local KEY_NAME = "Key"
- local debounce = false
- local function removeKeyFromPlayer(player)
- local backpack = player:FindFirstChild("Backpack")
- local character = player.Character
- if backpack then
- local key = backpack:FindFirstChild(KEY_NAME)
- if key and key:IsA("Tool") then
- key:Destroy()
- return true
- end
- end
- if character then
- local key = character:FindFirstChild(KEY_NAME)
- if key and key:IsA("Tool") then
- key:Destroy()
- return true
- end
- end
- return false
- end
- part.Touched:Connect(function(hit)
- if debounce then return end
- local character = hit:FindFirstAncestorOfClass("Model")
- if not character then return end
- local player = Players:GetPlayerFromCharacter(character)
- if not player then return end
- debounce = true
- removeKeyFromPlayer(player)
- task.wait(0.3)
- debounce = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment