Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] Sleeping at inn takes more cents each time you sleep?

Asked by
bluzorro 417 Moderation Voter
4 years ago
Edited 4 years ago
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.

0
Can you "print(price)" after taking the coins? I want to know if it changes. Nowaha 459 — 4y
0
it prints 5, but the second time i press it it prints twice.. let me see if adding a debounce works. bluzorro 417 — 4y
0
i really dont think it would help but try a debounce? Donut792 216 — 4y
0
ok now it works bluzorro 417 — 4y
View all comments (2 more)
1
tip:u should try and do this on the server becuz this can be easily hacked on the client Cjjdawg -9 — 4y
0
^^^ Really important, now the cash value only changes for the player. It won't update for the server nor for anyone else, so it basically does not take any money. Nowaha 459 — 4y

Answer this question