I'm new to scripting and am generally learning basic things, but i cant figure this out. Ill explain it the best that i can understand how too!
I got 2 separate local scripts, 1 that buys the potion and increases the amount and one that keeps account of a clicks value. I will have them placed in the order i spoke of them. But in the text Button i keep the local script I keep the track/Update clickValues, I also have an intValue which is what actually stores the value of my clicks the script itself just adds rebirths value to it. The problem is when i call that int value in the local script that lets the player buy potions to multiply the click amount, the intValue doesnt change.
Local Script - Buying Potion
--Buy potions Gui/ Multiplies CLick amount
local player = game.Players.LocalPlayer
local clicks = player:WaitForChild("leaderstats"):WaitForChild("Clicks")
local rebirths = player:WaitForChild("leaderstats"):WaitForChild("Rebirths")
local gems = player:WaitForChild("leaderstats"):WaitForChild("Gems")
-- tapAmount is connected to the Amount value in my click button.
local tapAmount = game.StarterGui.clicksGui.Clicks.Amount.Value
script.Parent.MouseButton1Click:Connect(function()
--Checks to see if the player has 20 gems, if so, it multiplies the tapAmount by 2 and removes 20 gems.
if gems.Value >= 20 then
wait()
tapAmount = tapAmount * 2
wait()
gems.Value = gems.Value - 20
end
--Sets button text to tell that gem amount is too low
if gems.Value < 20 then
tapAmount = tapAmount
wait()
script.Parent.Text = "Not Enough!"
wait(2)
script.Parent.Text = "Buy - 20 Gems"
end
end)
Local Script Adds clicks to the click value due to rebirths and connects the value of clicks to the click leaderstats
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local clicks = player:WaitForChild("leaderstats"):WaitForChild("Clicks")
local rebirths = player:WaitForChild("leaderstats"):WaitForChild("Rebirths")
local amount = script.Parent.Amount.Value
clicks.Value = clicks.Value + amount
--adds to click value after rebirths
if rebirths.Value > 0 then
clicks.Value = clicks.Value + rebirths.Value
end
end)

1 comment
would I use a client - server - client remote event then?