I have a bool value (CanBreak) that is placed inside of a folder inside of the player(not character). I have it set to false when it is created and I want it to change to true in certain parts of my script but nothing happens and it is all in a server script.

main = require(game:GetService("ServerScriptService"):WaitForChild("Modules"):WaitForChild("Main"))

game:GetService("Players").PlayerAdded:Connect(function(player)
	local canBreak = player:WaitForChild("Values"):FindFirstChild("CanBreak")
	
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		local head = character:WaitForChild("Head")
		local dist = 0
		local isInCircle = false
		local circle = nil
		
		while wait(.1) do
			local container = workspace:WaitForChild("Container"):GetChildren()
			
			for i = 1, #container do
				dist = container[i].Circle.Size.z - container[i]:FindFirstChild(container[i].Name).Size.z * 3
				if humanoid and head then
					if (head.Position - container[i].PrimaryPart.Position).magnitude < dist and humanoid.Health > 0 then
						if isInCircle then
							if circle == container[i] then
								container[i].Circle.Transparency = 0
								-- main.canBreak = true
								canBreak.Value = true					
							end
						else
							isInCircle = true
							circle = container[i]
							container[i].Circle.Transparency = 0
							-- main.canBreak = true
							canBreak.Value = true
						end
					else
						isInCircle = false
						circle = nil
						container[i].Circle.Transparency = 1
						-- main.canBreak = false
						canBreak.Value = false
					end
				end
			end
		end
	end)
end)

4 comments

0

So the contents of the Container folder are models with parts in each model?

0

don't you have to parent IsInCircle to the folder??

0

or make a boolvalue and put it in the folder

0

The bool value is CanBreak and it is in the Values folder