I was trying to create a script where when you touch a part the zombies would get unanchored. However, it didn't work. there were no red lines in the script. No errors were in the output menu So im not sure why its not working
The Code (Server Script)
1 | local zombies = game.Workspace.MainMap.Stage 1 Z.SZ 1 :GetChildren() |
2 | local part = game.Workspace.MainMap.UnAnchors.Part |
3 |
4 | function ZombieAnchor() |
5 | zombies.Anchored = false |
6 | end |
7 |
8 | part.Touched:Connect(ZombieAnchor) |
Please Help its not working
Try This:
1 | script.Parent.Touched:Connect( function (hit) |
2 | local human = hit.Parent:FindFirstChild( "Humanoid" ) |
3 | if (human ~ = nil ) then --Will detect only characters instead of parts ect |
4 | zombies.Anchored = false |
5 | end |
6 | end ) |
You cant just set multiple values to unanchored at once. You can use a loop to get all the parts and set them to unanchored individually.
01 | local zombies = game.Workspace.MainMap.Stage 1 Z.SZ 1 :GetChildren() |
02 | local part = game.Workspace.MainMap.UnAnchors.Part |
03 |
04 | function ZombieAnchor() |
05 | for i, v in ipairs (zombies) -- loop through all the parts |
06 | if v:IsA( "BasePart" ) then -- check if it is basepart so it can be anchored |
07 | v.Anchored = false |
08 | end |
09 | end |
10 | end |
11 |
12 | part.Touched:Connect(ZombieAnchor) |