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

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

Asked by
Plieax 66
6 years ago
Edited 6 years ago

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)
0
'this' is the button that you press Plieax 66 — 6y
0
what is the script a parent of? it can help people to help you 4PlayerGamingRoblox 38 — 6y
0
You can't use ":connect()". Use ":Connect()". D3LTA_Y 72 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

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)
0
localscript jesus GingeyLol 338 — 6y
Ad
Log in to vote
0
Answered by
D3LTA_Y 72
6 years ago

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)

Answer this question