New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How to have it print plr is anchored when player is anchored?

Asked by 1 year ago
if game.Player.LocalPlayer.Name.HumanoidRootPart.Anchored = true then 
print("Player is anchored") end

3 answers

Log in to vote
1
Answered by 1 year ago

Use GetPropertyChangedSignal() (this is a local script):

local player = game.Players.LocalPlayer
player.CharacterAdded:Connect(function(char)
    char.HumanoidRootPart:GetPropertyChangedSignal("Anchored"):Connect(function()
        if char.HumanoidRootPart.Anchored then
            print(player.Name .. " is anchored")
        end
    end)
end)

GetPropertyChangedSignal(property) fires when the value of property changes. It does this every time it changes.

0
"GetPropertyChangedSignal(property) fires when the value of property changes. It does this every time it changes." is not 100% true, some properties like Position, when changed, do not fire the Changed event, or the event returned by :GetPropertyChangedSignal. They only fire if you change the property with Lua User#24403 26 — 1y
Ad
Log in to vote
1
Answered by
Alphexus 429 Moderation Voter
1 year ago

I don't know when you want it to print out, but this should work. I hope this helped. You could also use GetPropertyChangedSignal to print out when the character's humanoid root part or torso is changed. Thanks and keep on scripting :D

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

if char:FindFirstChild("HumanoidRootPart") then -- Change to "Torso" if R6
    if char.HumanoidRootPart.Anchored == true then
        print("Anchored")
    else
        print("Unachored")
    end
end
Log in to vote
-2
Answered by
OnaKat 444 Moderation Voter
1 year ago
while true do
if game.Players.LocalPlayer.Character.HumanoidRootPart.Anchored == true then
print("Player is anchored")
end
wait()
end
0
There's such a thing as `GetPropertyChangedSignal`. TheeDeathCaster 2309 — 1y
1
I really want to downvote this answer. Not enough rep though :( l Psudar 853 — 1y
0
dont worry i did it for u User#24403 26 — 1y

Answer this question