Answered by
7 years ago Edited 7 years ago
Swimming
is an event of the Humanoid object.. you can't "check" an RbxScriptSignal and expect it to return if the player is swimming or not.
I suggest you use the StateChanged
event of the Humanoid object. It fires when the state of the humanoid changes(e.g. Jumping, Falling, Dead, swimming). It returns the previous state of the humanoid, and the current state.
You can compare the second returned value with the HumanoidStateType Enum.
01 | local p = game.Players.LocalPlayer |
02 | local c = p.Character or p.CharacterAdded:Wait() |
03 | local h = c:WaitForChild( "Humanoid" ) |
04 | local target_state = Enum.HumanoidStateType.Swimming |
07 | h.StateChanged:Connect( function (old,new) |
08 | if new = = target_state then |
10 | print (c.Name.. " went from " .. tostring (old).. " to " .. tostring (new).. "!" ) |