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

How do i gain access to "Humanoid" when clicking a button?

Asked by
ZO0PPY 25
3 years ago
Edited 3 years ago
-- Here's my script, "I'm using a "LocalScript".


-----------

local part = script.Parent


local cd = part.ClickDetector

cd.MouseClick:Connect(function(playerwhoclicked)
    playerwhoclicked.Character.Humanoid.WalkSpeed = 100
end)
0
Please use codeblock. Dovydas1118 1495 — 3y
0
Why would you change the walkspeed via a local script? User#34929 0 — 3y
0
I've tried it on a normal script, but doesn't seem to work as well, i have no clue what "codeblock" is as well. I'm sorry, i'm just new to lua coding. And i'm trying to learn it at a fast pace with the right people. ZO0PPY 25 — 3y
0
well first of all, you don't have to get the player who clicked, since you are accessing it with a local script User#34929 0 — 3y
View all comments (5 more)
0
you just have to get the local player by writing: Player = game.Players.LocalPlayer and then do Player.Character.Humanoid.WalkSpeed = 100 User#34929 0 — 3y
0
the "and then do" is not part of the script, just so you know User#34929 0 — 3y
0
Wait, let me just write an answer User#34929 0 — 3y
0
@ZO0PPY, Edit the answer, click the lua button, and copy and paste your code inside it. I'm not gonna answer anything that doesn't have code block. That includes you, @KochbananemitGuave . I'm getting tired of newbies not using code block. Dovydas1118 1495 — 3y
0
Inside a comment?? User#34929 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

LocalScripts don't run in the Workspace, making it a Script should work without any errors.

Hope this helped

Ad

Answer this question