Hello developers! I have a problem with the script, I mean if someone buys a Teleport through the GUI they don’t lose their gems.
Local Script(Buying Teleport when its locked. Script is in GUI)
for i,v in pairs(script.Parent.TeleportBg.ScrollingFrame:GetChildren()) do
v.MouseButton1Click:Connect(function()
if v:FindFirstChild("Locked") then
script.Parent.StepTwo.Visible = true
script.Parent.TeleportBg.Visible = false
script.Parent.StepTwo.Price.Value = v.Price.Text
script.Parent.StepTwo.World.Value = v.Name
script.Parent.StepTwo.Info.Text = "Do you want to buy "..script.Parent.StepTwo.World.Value.." for "..script.Parent.StepTwo.Price.Value.." Gems?"
script.Parent.StepTwo.YES.MouseButton1Click:Connect(function()
if plr.leaderstats.Gems.Value >= script.Parent.StepTwo.Price.Value then
game.ReplicatedStorage.BuyTeleport:FireServer()
v.Locke`Preformatted text`d:Destroy()
end
end)
end
end)
end
Script(Remote Event. Script is in ServerScriptService)
game.ReplicatedStorage:WaitForChild("BuyTeleport").OnServerEvent:Connect(function(plr, Teleport)
if Teleport and Teleport.Parent == plr.PlayerGui.Main.StepTwo then
local gems = plr.leaderstats.Gems
if gems.Value >= Teleport.Price.Value then
gems.Value -= Teleport.Price.Value
end
end
end)
I have no idea how to fix that.