Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to check local humanoid if seated?

Asked by 5 years ago

Hi! Im wondering how you can make a script that can check the local humanoid if he is seated. And after that, I want to have another line that prints "hi it worked" only if the local player is seated. I'm not gone dislike and comments unless it's just trolling. Any ideas are helpful for me so please feel free to at least try to find a solution. Thank you so much.

0
There is no "local humanoid" only humanoid Robloxian_Hero1234 14 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Humanoid is a object placed in every character model. Your character model is in workspace, where all the world objects appear.

-- this is a script to access it:

function humanoid(param)
if param:IsA("Model") and param.Humanoid then return param end
end

hum = workspace.ChildAdded:Connect(humanoid)

Player is the client. You use this instance when you simply want to do things on the client side like how your character is on the server.

localp = game.Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
gui = localp.PlayerGui.ScreenGui.Frame
-- your gui goes there ^
-- now
if hum.Sit and hum:GetState() == 13 then
gui.Visible = false
else
gui.Visible = true
end

That is the script... Now you may want to do this too, but your choice.

hum:GetPropertyChangedSignal("Sit"):Connect(function(change)
if change then
gui.Visible = false
else
gui.Visible = true
end
end)
1
`WaitForChild("LocalPlayer",4.5)` LocalPlayer is a property, not an object. `IsAncestorOf` takes an object, not a string value. `GetChangedPropertySignal` is an event, which fires when a value changes, so `Connect` is needed. There's no enum value by the name of `Enum.HumanoidStateType.13`; did you mean `Hum:GetState() == 13`? TheeDeathCaster 2368 — 5y
0
Thank you. What he said ^ Robloxian_Hero1234 14 — 5y
0
Might I suggest covering the StateChanged and CharacterAdded events in your solution? https://developer.roblox.com/api-reference/event/Humanoid/StateChanged https://developer.roblox.com/api-reference/event/Player/CharacterAdded M39a9am3R 3210 — 5y
0
Absolutely! Robloxian_Hero1234 14 — 5y
View all comments (4 more)
0
I want to show him the inner workings of workspace:CharAdded to give him some learning space! Robloxian_Hero1234 14 — 5y
1
I actually wouldn't recommend the workspace.ChildAdded event as it will execute that if statement every time something is added to the Workspace. This is just inefficient and unnecessary since you're given the CharacterAdded and StateChange events. M39a9am3R 3210 — 5y
0
Hey Robloxian_Hero1234 Thank you so mutch for the awsners. But i quite don't understand what you mean. Would you like to chat/talk on discord? Thanks. Skydoeskey 108 — 5y
0
After the humanoid has been achieved it should disconnect good point and disc: Matheusx#3245 Robloxian_Hero1234 14 — 5y
Ad

Answer this question