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

How to access player parts?

Asked by
Paradoa 17
3 years ago

How would I access player parts? For example, if I wanted to destroy the player's hand when the player steps on a brick. The script below

local debounce = false
local brick = script.Parent

brick.Touched:Connect(function(activate)
    if not debounce then
        debounce = true
        local humanoid = activate.Parent:FindFirstChild("Humanoid")
        if humanoid then
            local player = game.Players:FindFirstChild(activate.Parent.Name)
            player.RightHand.Disabled = true
        end
    end
end)

isn't working. There isn't any output either. Please help.

1 answer

Log in to vote
0
Answered by
n_ubo 29
3 years ago
Edited 3 years ago

try this

local debounce = false
local brick = script.Parent

brick.Touched:Connect(function(hit)
    if debounce == false then
        debounce = true
        local humanoid = hit.Parent:FindFirstChild("Humanoid")
        if humanoid then
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.Character.RightHand.Disabled = true --i hope you defined righthand correctly
        end
    end
end)

if RightHand is in fact a part or an union, you cant disable it, if you want it gone do

player.Character.RightHand:Destroy()
Ad

Answer this question