local player = game.Players.LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local playerGui = player:WaitForChild("PlayerGui") local humanoid = char:WaitForChild("Humanoid") local dialog = game.ReplicatedStorage.Dialog local interact = game.ReplicatedStorage.Interact local price = 5 if player.Data.Coins.Value >= price then player.Data.Coins.Value = player.Data.Coins.Value - price -- This is the line that removes 5 coins each time. blackscreen.Parent = playerGui dialog.Continue.Visible = false dialog.Cancel.Visible = false dialog.NameBox.TextLabel.Text = "" dialog.Text.TextLabel.Text = "" dialog.Parent = game.ReplicatedStorage interact.Parent = game.ReplicatedStorage for i = 0, 1.02, 0.02 do blackscreen.Background.Size = UDim2.new(i, 0, i, 0) game:GetService("RunService").Heartbeat:Wait() end wait(2) for i = 1.02, -0.02, -0.02 do blackscreen.Background.Size = UDim2.new(i, 0, i, 0) game:GetService("RunService").Heartbeat:Wait() end player.Data.HP.Value = humanoid.MaxHealth humanoid.WalkSpeed = 25 interact.TextLabel.Visible = true end
What I'm trying to do is, whenever you sleep at an inn, it will take 5 coins and then you will have full HP. The problem is if you do it repeatedly, the price rises by 5 and I don't know why.