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)

2 comments

0

can you explain this more clearly? what is green?

0

green is a door where the string value that gets the player is.

2 answers

✓ Accepted answer

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

0

there is something wrong. The local green = game.Workspace.green:GetChildren() is very correct if you change it the script will fail.

0

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

0

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

0

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

0

thats why i put get child

0

which line

0

also i have tested the probability of GetChildren() by defining a part in the workspace via

0

local part = workspace:GetChildren().Part; print(part)

0

which showed no success

0

so it is technically proven

0

also u do realize im spending a lot of time trying to correct u on this simple point

0

oh look at the model

0

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

0

green(model) - GREEN (brick) - PLRNAME (Stringvalue) and The script that gets the name.

0

@hvcu i have tested that too and it also yielded the same results

0

so if u dont get this problem fixed we will not get answer

0

also i still dont understand ur purpose of this contraption

0

oh looks like i have to test.

0

also where is the script located at?

0

is located in a brick that is located in a model

0

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

0

u could put the script in the model's part

0

it also gives me no error

0

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.

0

@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

0

if i got backup from the community would u belive me?

0

dude im trying to help u here

0

wait a minute, isnt PLRNAME a string value and it should be PLRNAME.Value?

0

correct that was what i said

0

well, not exactly, but its kinda

0

i made it more clear, now GREEN will remain GREEN and another thing will change name but why it still DOSENT WORK???

0

also i cant think of an idea o what ur gonna use this for

0

because green:GetChildren y wont u believe me dude

0

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.

0

uhhhh u know that is a completely wrong strategy to do thing right

0

ok. . .

0

this can be resolved very easily.

0

ok then how

0

also im certain it will work if u dont use :GetChildren()

0

ok ill edit my answer gimme a minute

0

i removed it but still dosent work...

0

cus there is more then one thing wrong here

0

im gonna test

0

also have u not heard of the scientific method?

0

scientific method ... no

0

ok that explains everything

0

it works but i think it still can be clicked by more persons...

0

well is it disabled?

0

ok look very easy: make a whitelisted table; anyone thats whitelisted is capable of buying stuff

0

and set a limit to said table

0

it was but yestarday i was testing with my friend and when he clicked it worked for him (but i was owning the tycoon)

0

ok look team create me a baseplate ill show u de wae

0

cuz your the best im 80% sure that i fixed it thanks

0

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

0

and @hvcu at this said time im actually probably am

0

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?

0

no u do for i, v in pairs(table) do

0

thanks

0

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?

0

worked!!!!!

0

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

0

: )

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