local deb = false
script.Parent.Touched:connect(function(hit)
if deb == false then deb = true
local char = hit.Parent
local plr = char:GetPlayerFromCharacter(char)
if plr:FindFirstChild("Good") then
if plr.Good.Stolen.Value == true then
print("Stolen")
end
end
else
print("Y u n0 w0rk?")
end
wait(2)
deb = false
end)
✓ ANSWER ACCEPTED
Why isnt GetPlayerFromCharacter() working?
2 answers
✓ Accepted answer
Your problem is that you're attempting to call the GetPlayerFromCharacter() method from the character, whilst it is a method from Players. Use the method off of game.Players to fix(:
local deb = false
script.Parent.Touched:connect(function(hit)
if deb == false then deb = true
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr and plr:FindFirstChild("Good") then
if plr.Good.Stolen.Value == true then
print("Stolen")
end
end
else
print("Y u n0 w0rk?")
end
wait(2)
deb = false
end)
local deb = false
script.Parent.Touched:connect(function(hit)
if deb == false then deb = true
local char = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
if plr:FindFirstChild("Good") then
if plr.Good.Stolen.Value == true then
print("Stolen")
end
end
else
print("Y u n0 w0rk?")
end
wait(2)
deb = false
end)
Instead of char:GetPlayerFromCharacter(char) you need to do game.Players:GetPlayerFromCharacter(char).
This discussion is preserved as it was. New answers, comments, and votes are closed.
