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

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

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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.

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. Thundermaker300 554 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
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)

Answer this question