I try to make a commanding model, but it doesn't seem to get the model's Humanoid.\
local rp = game:GetService("ReplicatedStorage") local remote = rp:FindFirstChild("Z") remote.OnServerEvent:Connect(function(player, val, Mouse) if val == "CommandZombie" then local Zombiepet = workspace:GetChildren(player.Name.."'s Pet") local zomNoid = Zombiepet:FindFirstChild("HumanoidRootPart") print(("ZOmbieeeeeee")) if Zombiepet and zomNoid then print(("ZOmbie")) local bodyposition = Instance.new("BodyPosition") bodyposition.Parent = zomNoid bodyposition.MaxForce = Vector3.new(10000,10000,10000) Zombiepet.Position = Mouse game.Debris:AddItem(bodyposition, 4) end end end)
On line 10, workspace function GetChildren
(https://developer.roblox.com/en-us/api-reference/function/Instance/GetChildren) returns an array of children parented under workspace. In this case, the arguments wouldn't have any change on the returned values. (Note: this applies to some functions.)
I suggest changing GetChildren
to FindFirstChild
.
Sample script proving that the arguments of GetChildren
have no influence on the returned values.
local workspace = workspace local t1 = workspace:GetChildren() local t2 = workspace:GetChildren('wow potato') for a=1,#t1 do print(t1[a]==t2[a]) -- true end