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

Why doesn't this script work?

Asked by 10 years ago
script.Parent.MouseClick:connect(function() game.Players.LocalPlayer.Character.Humanoid.Health = 0 end)

It's in a clickdector, its a script so if you click the brick, they die but wont work in-game, only works in studio

0
Is this in a LocalScript? adark 5487 — 10y
0
No DevScripting 92 — 10y
0
I'll try, again too put in local script DevScripting 92 — 10y
0
Local script failed DevScripting 92 — 10y

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

Alright, your problem is that you can't access LocalPlayer from a normal Script in a live Server.

Luckily, ClickDetectors' MouseClick returns an argument that is the Player who clicked, allowing you to do this:

script.Parent.MouseClick:connect(function(plyr)
    plyr.Character.Humanoid.Health = 0
end)
0
DUDE DevScripting 92 — 10y
0
THANX AT ADARK DevScripting 92 — 10y
Ad

Answer this question