This Script Seems Broken

Hello, I am an noobie scripter. So I don’t know much about scripting.

When I was making this part that when a human touches it is supposet to fall. But yet i have the thing set up as (a human touches it (wait 0.2 seconds)) but yet it only works for one of the block. I tried to make it like:

game.Workspace.Part2.Anchored = false

(and yes, I name the parts “Part1” and “part2”.)

Here is the script. And here is an image:

image
Raw Material:

local function Hit()

game.Workspace.Part.Achored = false
wait(1)
game.Workspace.Part.Achored = true

end

game.Workspace.Part.Touched:Connect(Hit)

Some help would be much helpful!!!

I’m probably as new as you, but in your code block you spelled “anchored” incorrectly.

5 Likes

As @Vintage_Jr said, you mispelled Anchored.

Second, .Touched happens when any part hits the part.

Third, You are not using a debounce so whenever the part gets touched the function will be spammed.

3 Likes

see though, the script work. But it only work for 1 part so ill have the script in 5 blocks but it only works for one.

Then show the full script that you have right now.

that is really weird though, because the script only works for one, eveven though I spelt anchored wrong…

Try this:

game.Workspace.Part.Touched:Connect(hit)
game.Workspace.Part.Anchored = false
wait(1)
game.Workspace.Part.Anchored = true
end

oop- That was my first script mmyy bad…

image

don’t ask about my function name please.

So the script doesn’t work, correct?

1 Like

so, it works, but… I have two parts right… and I have the script in both of th blocks/parts but when I touch the first part it unanchores, but when I touch the second part, it doesn’t. The same script in the same block. (So like one script go in one bock, and one script goes in the second block (same script))

Did you modify it for the second part?

1 Like

Ill see if i can take a video.

no just named part. (and yes Ive tryed to alter the script and alter the name of the block. So like Nameing the block Part1 and changing the script to Part1 and same for the other part but just named Part2.

local Part = game.Workspace.Part
local Debounce = false

local function Anchor(Hit)
  if Hit.Parent:FindFirstChild("Humanoid") ~= nil then --Make sure the part that got hit is a Character
    if Debounce == false then -- Stops function from being spammed
      Debounce = true
      Part.Anchored = true
      wait(1)
      Part.Anchored = false
      wait(1)
      Debounce = false
    end
  end
end

Part.Touched:Connect(Anchor)
1 Like

Try doing this:

local function Hit()

game.Workspace.Part1.Anchored = false

wait(1)

game.Workspace.Part1.Anchored = true

game.Workspace.Part2.Anchored = false

wait(1)

game.Workspace.Part2.Anchored = true

end

game.Workspace.Part1.Touched:Connect(Hit)

game.Workspace.Part2.Touched:Connect(Hit)
1 Like

so before I read these he is the video, I’m allowed to post this video right. It just studio…

Try putting them both in ServerScriptService.

1 Like