I need to have a part identify the player's walkspeed for it to turn off CanCollide. I must do this by locating the player's humanoid.
Here is an example of finding the humanoid:
01 | local sp = script.Parent |
02 | local h = 35 |
03 | local c = 5 |
04 | local d = true |
05 |
06 | sp.Touched:connect( function (part) |
07 | local char = part.Parent |
08 | local human = char:FindFirstChild( "Humanoid" ) --Identifies the Humanoid |
09 | if human and d then |
10 | if human.Health > 0 and human.Health < human.MaxHealth then |
11 | d = false |
12 | local ch = human.Health |
13 | local nh = ch + h |
14 | human.Health = nh |
15 | sp.Transparency = . 5 |
Okay, I'm going to make a part's cancollide change to false if they player touching it has a walkspeed of 25 or greater.
01 | --This script is parented to the part that is going to check if the player has a walkspeed of 25 or greater |
02 |
03 | local part = script.Parent |
04 | local validWalkspeed = 25 |
05 |
06 | part.Touched:Connect( function (hit) |
07 | local player = game:GetService( "Players" ):GetPlayerFromCharacter(hit.Parent) |
08 | if player then |
09 | local humanoid = player.Character:WaitForChild( "Humanoid" ) |
10 | if humanoid then |
11 | if humanoid.WalkSpeed > = validWalkspeed then |
12 | print (player .. " has a walkspeed greater than/equal to 25!" ) |
13 | part.CanCollide = false |
14 | else |
15 | print (player .. " doesn't have a walkspeed greater than/equal to 25!" ) |
16 | end |
17 | end |
18 | end |
19 | end ) |