I have multiple NPC's with the same name in Workspace. They all have a bool value. How do I change the values of the bool value in all of the NPC's when I press a button?
`local Button = script.Parent
local function LeftClick()
local Npc1WS = game.Workspace:GetChildren() for i,v in pairs(Npc1WS) do if v:IsA("Model") then v.Stats.Actions.Halt.Value = true end end
end
Button.MouseButton1Click:Connect(LeftClick)`
local Button = script.Parent local function LeftClick() local Npc1WS = game.Workspace:GetChildren() for i,v in pairs(Npc1WS) do if v:IsA("Model") then if v:FindFirstChild"Stats".Actions then -- should be good v.Stats.Actions.Halt.Value = true end end end end Button.MouseButton1Click:Connect(LeftClick)
If this doesn't work, please don't hesitate to contact me!