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

How can i make it so if the player touches a GUI button it's HumanoidRootPart gets referenced?

Asked by 4 years ago

I have no idea how would i do it HELP ME! thanks!

1 answer

Log in to vote
0
Answered by
lunatic5 409 Moderation Voter
4 years ago

What I think you're trying to do is get a player's HumanoidRootPart when they click a GUI button. To do this, we can put a LocalScript (this is important) in the button with the following code:

--Get the player
local player = game:GetService("Players").LocalPlayer

--When the button is pressed
script.Parent.Activated:Connect(function()
    local humanoidRootPart = player.Character.HumanoidRootPart
end)

Hope this helps.

0
Can it be instead of activated, MouseButton1Click? is it the same? Pipe_Gamerz 4 — 4y
0
Yes it can be. MouseButton1Click, however, is slowly less commonly being used in favor of Activated, so I suggest you use Activated now before MouseButton1Click gets deprecated. lunatic5 409 — 4y
Ad

Answer this question