Hi I'm trying to make an obby where a part has to do with Gravity Falls. If you know that programme you will know the eye bats who turn people to stone. I just need code for when you hit a part you turn to stone colour and freeze, then after a second die. Someone has suggested some code before but once used nothing happened. I'm not really a coder so can someone please help. Thanks
Btw here is the code aforementioned.
game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) wait(1) for a, b in pairs(Character:GetDescendants()) do if b:IsA("BasePart") then b.Touched:Connect(function(hit) if hit.Parent.Name == "EyeBat" then for c, d in pairs(Character:GetDescendants()) do -- Set Color local color = Color3.fromRGB(150, 150, 150) if d.Name == "Body Colors" then d.HeadColor3 = color d.RightArmColor3 = color d.LeftArmColor3 = color d.RightLegColor3 = color d.LeftLegColor3 = color d.TorsoColor3 = color -- Set Frozen (d.Anchored = true is possible) elseif d.Name == "Humanoid" then d.WalkSpeed = 0 d.JumpPower = 0 -- Removes Shirt Id (Optional) elseif d.Name == "Shirt" then d.ShirtTemplate = "" --Removes Pants Id (Optional) elseif d.Name == "Pants" then d.PantsTemplate = "" end -- Changes Material / PartColor to Slate / Grey if d:IsA("BasePart") then d.Material = Enum.Material.Slate d.Color = color -- Makes Accessories Grey (Optional) elseif d:IsA("SpecialMesh") then d.TextureId = "" end end end end) end end end) end)
Place this script into the part you want them to touch i have explained the functions for you below
script.Parent.Touched:Connect(function(hit) -- detects touch if hit.Parent:FindFirstChild('Humanoid') then -- check if player hit.Parent.Humanoid.WalkSpeed = 0 -- set player movement speed to 0 hit.Parent.Humanoid.JumpPower = 0 -- set jumping force to 0 for i,v in pairs(hit.Parent:GetChildren()) do -- get all players children if v:IsA("BasePart") then -- check if player's children are parts v.BrickColor = BrickColor.new("Dark stone grey") -- change skin color end end wait(2) hit.Parent.Humanoid.Health = 0 -- kill player end end)