An element of my game is where you can upgrade your house through a UI. My script is supposed to check if you have enough money, make the cloner variable true which will run the distance check, and if you're far enough it should make the distance true. When distance is true it is supposed to run the rest of the script by using an if statement, but it doesn't seem to be running it. The first if statement is basically the exact same and runs fine. Can somebody help me out? (this is a localscript)
local cloner = false
local distance = false
local gui = script.Parent
local player = game.Players.LocalPlayer
local RemoteEvent = game:GetService("ReplicatedStorage")
local remote = RemoteEvent:WaitForChild("Remote1")
local tier1 = workspace.Buildings.floor1
local range = (tier1.root.Position-game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position).magnitude
script.Parent.MouseButton1Click:Connect(function(distance, cloner)
local ls = player:FindFirstChild('leaderstats')
local cash = ls:FindFirstChild('Money')
if cash.Value >= 10000 then
cash.Value = cash.Value - 10000
script.Parent.Parent.Parent.happymoner.Visible = true
local cloner=true
if cloner then
print("cloner is true, checking for distance")
if range <= tier1.mindist.Value then
local distance=true
if distance then
print("Distance is true, cloning")
script.Parent.BackgroundColor3 = Color3.new(0.588235, 0.584314, 0.596078)
script.Parent.Text = "Owned!"
script.Disabled = true
remote:FireServer()
end
end
wait(5)
script.Parent.Parent.Parent.happymoner.Visible = false
else
script.Parent.Parent.Parent.moner.Visible = true
wait(3)
script.Parent.Parent.Parent.moner.Visible = false
end
end
end)
This part is what it won't run
if cloner then
print("cloner is true, checking for distance")
if range <= tier1.mindist.Value then
local distance=true
if distance then
print("Distance is true, cloning")
script.Parent.BackgroundColor3 = Color3.new(0.588235, 0.584314, 0.596078)
script.Parent.Text = "Owned!"
script.Disabled = true
remote:FireServer()
end
end
