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

How do I make an image button that can find the player who clicked it?

This is what I have on my script right now. What i want it to do is make the folder value be true only if the file this is activated. But when I run this in my game it instantly makes the folder value true. How do I fix this?

local this = script.Parent

game.Players.PlayerAdded:connect (function(plr)
				
		local folder = Instance.new ("BoolValue",workspace)
		folder.Name = (plr.Name .. "click")
		
		if this.Activated then
			folder.Value = true
		end
end)

3 comments

0

'this' is the button that you press

0

what is the script a parent of? it can help people to help you

0

You can't use ":connect()". Use ":Connect()".

2 answers

You don't handle PlayerAdded from a LocalScript. Just use a LocalScript and use the LocalPlayer.

--LocalScript

script.Parent.MouseButton1Click:Connect(function()
    print(game:GetService("Players").LocalPlayer.Name)
end)

1 comment

0

localscript jesus

Organization is essential.

--Made by Lunatic_o
-- I don't know if it will work. (I'm on mobile)

local this = script.Parent
this.Activated = false

function CheckThis()

      if assert(this.Activated) then
            print("This is Activated")
            workspace.YoutFolder.Value = true
      end
end



game.Players.PlayerAdded:Connect(function(plr)

   local folder = Instance.new("BoolValue", workspace)
   folder.Value = false
   folder.Name = "YourFolder"

end)

this.Activated.Changed:Connect(CheckThis)

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