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

Sit detection local script not working?

Asked by
zomspi 541 Moderation Voter
4 years ago

This local script doesn't make the surface GUI children visible?

    game.Players.LocalPlayer.Character.Humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
    if game.Players.LocalPlayer.Character.Humanoid.Sit == true then
        script.Parent.Screen.SurfaceGui.ScrollingFrame.Visible = true
        script.Parent.Screen.SurfaceGui.Laptop.Visible = true
        else
        script.Parent.Screen.SurfaceGui.ScrollingFrame.Visible = false
        script.Parent.Screen.SurfaceGui.Laptop.Visible = false
        end
    end
0
because sit isnt a property so you cant check that, you have to check the humanoid:GetState() or whatever that one is called Gameplayer365247v2 1055 — 4y
0
Humanoid.Sit is actually a property... Utter_Incompetence 856 — 4y

3 answers

Log in to vote
1
Answered by
zomspi 541 Moderation Voter
4 years ago

This is my finished script ,it still doesn't work?

local isSitting = false
   game.Players.LocalPlayer.Character.Humanoid.StateChanged:Connect(function(old, new)
    if game.Players.LocalPlayer.Character.Humanoid.Sit then

        script.Parent.Screen.SurfaceGui.ScrollingFrame.Visible = true
        script.Parent.Screen.SurfaceGui.Laptop.Visible = true
        else
        script.Parent.Screen.SurfaceGui.ScrollingFrame.Visible = false
        script.Parent.Screen.SurfaceGui.Laptop.Visible = false
        end
    end
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local plr =  game.Players.LocalPlayer
local char = plr.Character
local hum =  char:WaitForChild("Humanoid")

hum.HumanoidStateChanged:Connect(function(old, new) --Fires when a humanoid's state changes
    if hum.Sit then  --If  we're sitting...
        --code
    elseif not hum.Sit then  --If we're not...
        --code
    end
end)

0
I tried that but it didn't work, my modified version of your script is below zomspi 541 — 4y
Log in to vote
-1
Answered by 4 years ago

good explanation how to properly script this can be found here https://developer.roblox.com/en-us/api-reference/event/Humanoid/StateChanged

Answer this question