Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Please help me why this script dosent works? There is a string value that gets somehow the plr name.

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)   

1 comment

0

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

2 answers

✓ Accepted answer

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

0

yes also btw while ur here back me up

0

he also used part:GetChildren().Part right? thats wrong as well right?

0

no

0

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

0

but part:GetChildren().Part should be incorrect right? i mean, i tried printing it like that..

0

oh...then yes, it would be. In that case, it would find a child of the children already being found.

0

wait ill post it as a question

This discussion is preserved as it was. New answers, comments, and votes are closed.