The script changes the BoolValue to true but the onChanged doesn't detect the change, what am I doing wrong?
local seconds = 9
while not script.Parent.Parent.spawned.Value do
wait(1)
seconds = seconds - 1
script.Parent.Parent.GuiPart.BillboardGui.Frame.TextLabel.Text = seconds
if seconds == 0 then
script.Parent.Parent.spawned.Value = true
end
end
local function onChanged(NewValue)
print(NewValue)
if script.Parent.Parent.spawned.Value == true then
script.Parent.Parent.spawned.Value = false
local crateModel = Instance.new("Model")
crateModel.Parent = workspace
local spawnBase = script.Parent
local crates = game.ServerStorage.Crates.T4Crates:GetChildren()
local randomCrate = crates[math.random(1, #crates)]
local pos = Vector3.new(math.random(-spawnBase.Size.x/2, spawnBase.Size.x/2), spawnBase.Size.y/2, Vector3.new(spawnBase.Size.Y+10), math.random(-spawnBase.Size.z/2,spawnBase.Size.z/2))
local rotation = randomCrate:SetPrimaryPartCFrame(spawnBase.CFrame * CFrame.new(pos))
randomCrate.Handle.BodyForce = Vector3.new(0, randomCrate.Handle:GetMass()* 196.2, 0)
end
end
script.Parent.Parent.spawned.Changed:Connect(onChanged)

4 comments
Try using GetPropertyChangedSignal("WhateverProperty"). It fires whenever the property of the object changes. for example: script.Parent.Bool:GetPropertyChangedSignal("Value"):Connect(function(). It'll fire when the "value" property of the object bool changes
Still doesn't work @Dizzy
try using a coroutine
The argument passed into onChanged is supposed to be the name of the property, not the value of the property. (https://developer.roblox.com/en-us/api-reference/event/Instance/Changed)