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

GUI will not show up when you click on Dummy Torso!!! Help Please?

Your supposed to click on a Dummy's torso and it give you a shop GUI. This LocalScript inside the Dummy Torso. The Dummy is in the workspace.

Player = game.Players.LocalPlayer

script.Parent.ClickDetector.mouseClick:connect(function()
	local Shop = game.ServerStorage.Shop:Clone()
	Shop.Parent = Player.PlayerGui
	end
end)

2 answers

  1. "LocalPlayer" can only be accessed from LocalScripts. Switching the script to a LocalScript won't work, if this script is a decendent of workspace.

  2. mouseClick is not a property of ClickDetector. Remember, everything in scripting is case sensitive. Use MouseClick

  3. There's an unnecessary end in line 6

  4. :connect is deprecated. It's highly recommended you use :Connect.

Now, we have to solve a problem on how to get the player who clicked. MouseClick is an event that, when fired, will send a parameter that will contain the player who clicked.

script.Parent.ClickDetector.MouseClick:Connect(function(PlayerWhoClicked)
    local Shop = game.ServerStorage.Shop:Clone()
    Shop.Parent = PlayerWhoClicked.PlayerGui
end)

PRO TIP: Output will help you find errors in your code. Leave it open.

1 comment

0

There is actually a function called mouseClick that shows up when typing it out, but it's not in the API. He probably used that pop up.

local Player = game.Players.LocalPlayer

-- mouseClick needs to exactly spelt as MouseClick, because it's a special method
-- :connect should also be :Connect, because :connect is deprecated (aka do not use)
script.Parent.ClickDetector.MouseClick:Connect(function()

    local Shop = game.ServerStorage.Shop:Clone()
    Shop.Parent = Player.PlayerGui
end)

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