local green = game.Workspace.green:GetChildren()
function onClicked(plr) -- On click get player
if green.PLRNAME == plr.Name.Value then
script.Parent.Parent:Destroy()
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
Please help me why this script dosent works? There is a string value that gets somehow the plr name.
2 answers
the below is an answer repost(i wrote an answer to ur original question but u idk if u saw it so here is a repost):
ok so what im guessing is either
local green = game.Workspace.green -- i altered this part a bit
function onClicked(plr) -- On click get player
if green.PLRNAME == plr.Name.Value then
script.Parent.Parent:Destroy()
end
end
script.Parent.ClickDetector.MouseClick:Connect(function(plr) -- i also altered this part
onClicked(plr)
end)
or that
local green = game.Workspace.green -- i altered this part a bit
function onClicked(plr) -- On click get player
if green.PLRNAME == plr.Name then -- i also altered this part a bit
script.Parent.Parent:Destroy()
end
end
script.Parent.ClickDetector.MouseClick:Connect(function(plr) -- i also also altered this part
onClicked(plr)
end)
i apologize if this dusnt work ur question is also too broad btw
You are assigning it to the value instance but not its Value property. Change line 4 to this:
if green.PLRNAME.Value == plr.Name then
Assigning it to the StringValue is assigning it to the Instance, not the actual string that makes up the value. This is a very simple mistake many people make.
7 comments
yes also btw while ur here back me up
he also used part:GetChildren().Part right? thats wrong as well right?
no
GetChildren() is very similar to a single instance as you can find individual instances from it like if you were finding one instance under another
but part:GetChildren().Part should be incorrect right? i mean, i tried printing it like that..
oh...then yes, it would be. In that case, it would find a child of the children already being found.
wait ill post it as a question
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
green is a part that inserts the player name in a StringValue called PLRNAME.