GUI tool giver not giving tool when player clicks TextButton?
Goal: Player touches brick and opens a certain ScreenGUI. Then the user clicks on a TextButton to get a tool in their backpack.
Problem: The GUI (TextButton) is not giving the tool when clicked by a player.
Resources:
On Touch
"Brick": on touch, gives the player a certain ScreenGUI
"Giver": gives a gui whenever a players touches "Brick"
"Gui": the ScreenGui that shows when a player touches "Brick" (activated by 'Giver' script)
Tool Giver
"Gui": the ScreenGui that shows when a player touches "Brick" (activated by 'Giver script. this is located in "Brick" with the 'Giver' script
"Gui" (ScreenGui) -> "Frame" -> "TextButton" -> "Tool Giver" (local script)
Brick shows GUI on Touch
01 | local sp = script.Parent |
03 | local gui = script.Parent.Gui |
05 | sp.Touched:connect( function (hit) |
06 | if hit and hit.Parent:findFirstChild( "Humanoid" ) and db then |
08 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
09 | if not player.PlayerGui:findFirstChild( "Pop up" ) then |
10 | local newqui = gui:Clone() |
11 | newqui.Parent = player.PlayerGui |
GUI Tool Giver (Local script)
1 | local button = script.Parent |
2 | local tool = game.ServerStorage.ExampleTool |
3 | local plr = game.Players.LocalPlayer |
5 | button.MouseButton 1 Click:Connect( function () |
6 | tool:Clone().Parent = plr.Backpack |
Output: Script 'Players.ReasonxbIe.PlayerGui.Gui.Frame.TextButton.LocalScript', Line 2
-> local tool = game.ServerStorage.ExampleTool
Final Request: May anybody help me? I would like it so when a player touches a certain part, a ScreenGui will appear for ONLY that player. Then, the player can choose a tool by clicking the TextButton. When they click the button, they will be given the tool and the ScreenGui will close. They should be able to touch the part again and get another tool.