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

Can anyone help me with doubling the cost of clicks?

Asked by 2 years ago
Edited by imKirda 2 years ago

i have tried to get the double cost to work in a kinds of ways but it never seems to work. This is one of the attempts:

local player= game. Players, Localplayer
local Coins= player.leaderstats:FindFirstChild("Coins")
local Rebirths = player.leaderstats:FindFirstChild( "Rebirths")
local price = script. Parent.Price.Value
local amount= script.Parent.Amount.Value


script.Parent.MouseButton1Click:Connect(function()
if Coins.Value >= price then
Coins.Value = 0
Rebirths.Value += amount
price = price * 2
end
end)
0
game. Players, Localplayer should be game.Players.LocalPlayer, this "." means that you are trying to access property of something, in your case "LocalPlayer" property of "Players", also your script only changes Rebirths value locally only on your computer, no-one else will see this, see RemoteEvents to solve your issue imKirda 4491 — 2y
0
u7p4#6969 reeeeebot10 2 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

This script should work.

local player = game.Players.LocalPlayer
local Coins = game.leaderstats:FindFirstChild("Coins")
local Rebirths = player.leaderstats:FindFirstChild("Rebirths")
local price = script.Parent.Price.Value
local amount = script.Parent.Amount.Value
script.Parent.MouseButton1Click:Connect(function()
    if Coins.Value >= price then
        Coins.Value -= price
    end
    Rebirths.Value += amount
    price = price * 2
end)
0
game.leaderstats ? Punctist 120 — 2y
0
Change the game.leaderstats to player.leaderstats and that should work. co_existance 141 — 2y
0
if you could add me on discord and try and help that would be great i tried the code you put but i didn’t work reeeeebot10 2 — 2y
0
u7p4#6969 reeeeebot10 2 — 2y
0
i sent you a friend request on discord, tell me the error on there and i can fix it. LordKrox 39 — 2y
Ad

Answer this question