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
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
61 comments
there is something wrong. The local green = game.Workspace.green:GetChildren() is very correct if you change it the script will fail.
but it also fails anyways if u dont change it right? Logistically that would not prove its wrong it would simply not confirm that its correct
no. the problem is: The string is placed in a part. green is a model, GREEN is the acctual part. But after player goes in the door, the GREEN changes to player name, also the PLRNAME
im certain GetChildren() is very wrong a simple way to test this theory is to just define PLRNAME by itself. Now after u said that, i am unsure what u r doing
thats why i put get child
which line
also i have tested the probability of GetChildren() by defining a part in the workspace via
local part = workspace:GetChildren().Part; print(part)
which showed no success
so it is technically proven
also u do realize im spending a lot of time trying to correct u on this simple point
oh look at the model
no offense meant but ur point is practically like trying to say that the earth is flat; unless if u do believe it is which in that case i have no words
green(model) - GREEN (brick) - PLRNAME (Stringvalue) and The script that gets the name.
@hvcu i have tested that too and it also yielded the same results
so if u dont get this problem fixed we will not get answer
also i still dont understand ur purpose of this contraption
oh looks like i have to test.
also where is the script located at?
is located in a brick that is located in a model
how i can get a model's part without the exact name because THE NAME OF MODEL CHILD CHANGES maybe this will be the answer
u could put the script in the model's part
it also gives me no error
also that dusnt change a thing cus ur script also dusnt address that issue. Also also, u only need the name of the model before it changes.
@hvcu yes it does not yield error it yields "nil" if u attempt to print the part's name, which is basically means the script is unable to locate what u want
if i got backup from the community would u belive me?
dude im trying to help u here
wait a minute, isnt PLRNAME a string value and it should be PLRNAME.Value?
correct that was what i said
well, not exactly, but its kinda
i made it more clear, now GREEN will remain GREEN and another thing will change name but why it still DOSENT WORK???
also i cant think of an idea o what ur gonna use this for
because green:GetChildren y wont u believe me dude
umm i am making a tycoon. Im making this for the new things to buy, because other players can click on it. Thats why i am trying to make.
uhhhh u know that is a completely wrong strategy to do thing right
ok. . .
this can be resolved very easily.
ok then how
also im certain it will work if u dont use :GetChildren()
ok ill edit my answer gimme a minute
i removed it but still dosent work...
cus there is more then one thing wrong here
im gonna test
also have u not heard of the scientific method?
scientific method ... no
ok that explains everything
it works but i think it still can be clicked by more persons...
well is it disabled?
ok look very easy: make a whitelisted table; anyone thats whitelisted is capable of buying stuff
and set a limit to said table
it was but yestarday i was testing with my friend and when he clicked it worked for him (but i was owning the tycoon)
ok look team create me a baseplate ill show u de wae
cuz your the best im 80% sure that i fixed it thanks
its also a possibility ur friend sabotaged the script before he left to prevent u from learning the code scene as its ur game; leaving u to beleive false assumptions ultimately beleiveing GetChildren() which is actually just a table returning all the things in there
and @hvcu at this said time im actually probably am
this cant be real because 1 he dosent even know how to change roblox settings 2 he is my best friend . One more thing: Can i do if ... then and again if ... then?
no u do for i, v in pairs(table) do
thanks
gd it ill just give u an example of a table ill edit the answer, u know what nvm im guessin what i just said worked?
worked!!!!!
xd ok
This was succesfully fixed:
local green = game.Workspace.green
function onClicked(plr) -- On click get player
if green.GREEN.PLRNAME.Value == plr.Name and plr.leaderstats.Money.Value >=50 and plr.leaderstats.Machines.Value == 5 then
script.Parent.Parent:Destroy()
end
end
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
onClicked(plr)
end)
- Worked for me!!!
1 comment
: )
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
can you explain this more clearly? what is green?
green is a door where the string value that gets the player is.