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

Trying to :GetPlayerFromCharacter in a normal script, however I can't?

Asked by 7 years ago

So basically, I want it so when I click a brick, I can get the player.

script.Parent.ClickDetector.MouseClick:connect(function(plr)
    a = game.Players:GetPlayerFromCharacter(plr)
    a:Destroy()
end)

I have also tried this.

script.Parent.ClickDetector.MouseClick:connect(function(plr)
    local a = game.Players:GetPlayerFromCharacter(plr)
    a:Destroy()
end)
0
use this instead "local character = plr.Character if character ~= nil then character:Destroy()" NovusDev 25 — 7y

1 answer

Log in to vote
0
Answered by
Astralyst 389 Moderation Voter
7 years ago

What are you doing?

ClickDetector would already define the player for you, you don't need to use :GetPlayerFromCharacter, that's for other functions like onTouch, and et cetera.

Learn more about ClickDetector here: http://wiki.roblox.com/index.php?title=API:Class/ClickDetector/MouseClick

script.Parent.ClickDetector.MouseClick:connect(function(plr)
   plr:Destroy()
end)
Ad

Answer this question