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

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

Asked by
hvcu 3
5 years ago
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)   
0
green is a part that inserts the player name in a StringValue called PLRNAME. hvcu 3 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

Ad
Log in to vote
0
Answered by 5 years ago

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.

0
yes also btw while ur here back me up TheluaBanana 946 — 5y
0
he also used part:GetChildren().Part right? thats wrong as well right? TheluaBanana 946 — 5y
0
no DeceptiveCaster 3761 — 5y
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 DeceptiveCaster 3761 — 5y
View all comments (3 more)
0
but part:GetChildren().Part should be incorrect right? i mean, i tried printing it like that.. TheluaBanana 946 — 5y
0
oh...then yes, it would be. In that case, it would find a child of the children already being found. DeceptiveCaster 3761 — 5y
0
wait ill post it as a question TheluaBanana 946 — 5y

Answer this question