Ok so for context I'm making a script where the intended thing to happen is when you press the button it sets your walkspeed to 0. The catch is, the button is on yourself, aka its a starter character button. This is the script:
local OnButton = script.Parent
function turnOff(plr)
if game.StarterPlayer.StarterCharacter.Humanoid.WalkSpeed == 16 then
game.StarterPlayer.StarterCharacter.Humanoid.WalkSpeed = 0 and OnButton.BrickColor == BrickColor.new("Smoky grey")
end
end
OnButton.ClickDetector.MouseClick:Connect(turnOff)
So how do I go about fixing this script so it is working and clickable? Because right now what it does if you try to click the one on yourself it does nothing, does not consider it a button. But with another player, the clicking icon shows up, but it does not do the thing I wanted it to. Any help?

5 comments
This makes a lot more sense, and I feel like this should work and it seems like it would, but when I tried it out it hasn't changed anything, let me try with 2 players instead.
Yeah I tried it with 2 players and it still didn't work, thanks for trying though.
the player's character might be ignored when roblox is checking for a clickdetector. I'm not sure you can get around that if the ClickDetector part is inside the player's character.
Yikes, that sucks.
Ok so apparently I can alternatively use "mouse.Target", but I have no idea what it is and how to use it, continuing to search.