script.Parent.Triggered:Connect(function(player, hit)
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player and player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Coins") then
if player.leaderstats.Coins.Value > 50 then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 50
if not character:FindFirstChild("Key") and not player.Backpack:FindFirstChild("Key") then
local key = game.ReplicatedStorage:FindFirstChild("Key"):Clone()
key.Parent = character
script.Parent.Parent.Parent.GuidePart["Sparkle Tone Constant High End Shimmer Spark (SFX)"]:Destroy()
end
end
end
end)
script.Parent.Triggered:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Coins") then
if player.leaderstats.Coins.Value > 50 then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 50
if not player.Character:FindFirstChild("Key") and not player.Backpack:FindFirstChild("Key") then
local key = game.ReplicatedStorage:FindFirstChild("Key"):Clone()
key.Parent = player.Character
local soundEffect = script.Parent.Parent.Parent.GuidePart:FindFirstChild("Sparkle Tone Constant High End Shimmer Spark (SFX)")
if soundEffect then
soundEffect:Destroy()
end
end
else
print("Недостаточно коинов для покупки ключа.")
end
else
print("Ошибка: Игрок не найден или у него нет коинов.")
end
end)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.leaderstats.Coins.Valse > 50 then
player.leaderstats.Coins.Value = player .leaderstats.Coins.Value -50
if not player.Character:FindFirstChild("Key") and not player.Backpack:FindFirstChild("Key") then
local key = game.ReplicatedStorage:FindFirstChild("Key"):Clone()
key.Parent = player.Character
script.Parent.Parent.Parent.GuidePart["Sparkle Tone Constant High End Shimmer Spark (SFX)"]:Destroy()
end
end
end)
Скрипт для покупки ключей стоимость 50 коиной