I’m trying to make a script that clones something once a boolean value is true however it gives me an error saying, “attempt to index boolean with ‘Changed’”. I’m not sure how to fix this, what did I do wrong?
local robux = game:GetService("ServerScriptService"):WaitForChild("Robux")
local bool = game:GetService("ReplicatedStorage"):WaitForChild("Value")
bool.Value.Changed:Connect(function()
if bool.Value == true then
local robux2 = robux:Clone()
robux2.Parent = game:GetService("ServerScriptService")
wait(20)
robux2:Destroy()
end
end)
local robux = game:GetService("ServerScriptService"):WaitForChild("Robux")
local bool = game:GetService("ReplicatedStorage"):WaitForChild("Value")
bool.Changed:Connect(function()
if bool.Value == true then
local robux2 = robux:Clone()
robux2.Parent = game:GetService("ServerScriptService")
wait(20)
robux2:Destroy()
end
end)
local sss = game:GetService("ServerScriptService")
local rs = game:GetService("ReplicatedStorage")
local robux = sss:WaitForChild("Robux")
local bool = rs:WaitForChild("Value")
bool.Changed:Connect(function(newBool)
if newBool then
local robuxClone = robux:Clone()
robuxClone.Parent = sss
task.wait(20)
robuxClone:Destroy()
end
end)
local Debris = game:GetService("Debris")
local robux = game:GetService("ServerScriptService"):WaitForChild("Robux")
local bool = game:GetService("ReplicatedStorage"):WaitForChild("Value")
bool:GetPropertyChangedSignal:("Value"):Connect(function()
if bool.Value then
local robux2 = robux:Clone()
robux2.Parent = game:GetService("ServerScriptService")
Debris:AddItem(robux2, 20)
end
end)
Debris is perfect in this situation, as it will wait the 20 seconds, and destroy it, without yielding the code! Additionally, GetPropertyChangedSignal would be what you’re looking for - it will wait until Value has changed, and not the name, etc…
Furthermore, you can actually just use Bool.Value, and if it is false, it will return false. I believe that is it, let me know if you have any difficulties regarding this thread!