the script is:
local buyBlock = script.Parent
local clickDetect = buyBlock:WaitForChild("ClickDetector")
local config = buyBlock:WaitForChild("Configuration")
local DataStoreService = game:GetService("DataStoreService")
local BadgeService = game:GetService("BadgeService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BadgeID = config.BadgeID.Value
local coilStorage = ReplicatedStorage:WaitForChild("Toolss")
local coilStore = DataStoreService:GetDataStore("playerCoils")
local player = game.Players.LocalPlayer
local character = player.Character
local leaderstats = character:WaitForChild("leaderstats")
local money = leaderstats:WaitForChild(config.leaderstatCurrency.Value)
local tool = config.tool2buy.Value
local index = config.Index
local plrcoils = coilStore:GetAsync(player.UserId)
clickDetect.MouseClick:Connect(function()
if money.Value >= config.priceAmount.Value and (not plrcoils or not plrcoils["mainCoils"] or not plrcoils["mainCoils"][index]) then
plrcoils = plrcoils or {}
plrcoils["mainCoils"] = plrcoils["mainCoils"] or {}
plrcoils["mainCoils"][index] = index
local success, err = pcall(function()
coilStore:SetAsync(player.UserId, plrcoils["mainCoils"])
end)
if not success then
warn("Unable to save data to datastore: " .. err .. "Player: " .. player .. "Player Coils: " .. plrcoils)
-- player:Kick("An unexpected error occured. Maybe try rejoining.")
else
_G.coilStoreLocal[player.userId] = plrcoils
print("bought")
if config.deductCurrency.Value == true then
money.Value = money.Value - config.priceAmount.Value
end
tool:Clone().Parent = player.Backpack
buyBlock:WaitForChild("moneySound"):Play()
script.Parent.Material = Enum.Material.Neon
script.Parent.Part_green.Material = Enum.Material.Neon
task.wait(0.1)
script.Parent.Material = Enum.Material.SmoothPlastic
script.Parent.Part_green.Material = Enum.Material.SmoothPlastic
BadgeService:AwardBadge(player.UserId, BadgeID)
-- Teleport the player after a delay
end
else
-- print("not enough money or coil owned")
buyBlock:WaitForChild("errorSound"):Play()
script.Parent.Material = Enum.Material.Neon
script.Parent.Part_green.Material = Enum.Material.Neon
script.Parent.BrickColor = BrickColor.new("Really red")
script.Parent.Part_green.BrickColor = BrickColor.new("Really red")
task.wait(0.1)
script.Parent.Material = Enum.Material.SmoothPlastic
script.Parent.Part_green.Material = Enum.Material.SmoothPlastic
script.Parent.BrickColor = BrickColor.new("Forest green")
script.Parent.Part_green.BrickColor = BrickColor.new("Parsley green")
end
end)
and when i active it nothing happens and it gives 0 errors, i would be glad if someone help me
PS. “coils” saves on a table, in another script