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

working on a KeyBind Shop System , when i press the button does not open the shop gui. Help?

Asked by
AlexAecid -12
5 years ago
Edited 5 years ago

****as you read the title , that's the broblem , so basically i've created the "E" to open gui and inside i've put : a imagebutton inside i put: UIAspectRatioConstraint two text labes. (For the "E" and "To Open The Shop") and a local script , inside this script i've put :

local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(input,gameProcessed)
    if input.UserInputType == Enum.UserInputType.Keyboard then 
        if input.KeyCode == Enum.KeyCode.E then 
            if UIS:GetFocusedTextBox() == nil then 
                for i,v in pairs(game.Workspace.NPCs:GetChildren()) do
                    local mag = (v.UpperTorso.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude 
                    if mag <= 10 then -- 

                        for i = 1,0.6,-0.05 do
                            wait()
                            script.Parent.ImageColor3 = Color3.new(i,i,i)
                        end
                        wait()
                        for i = 0.6,1,0.05 do
                            wait()
                            script.Parent.ImageColor3 = Color3.new(255, 0, 0)
                        end

                        v.NPCTalk:FireServer()
                    end
                end
            end
        end
    end
end)

while wait() do
    script.Parent.Visible = false 
    for i,v in pairs(game.Workspace.NPCs:GetChildren()) do
        local mag = (v.UpperTorso.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude 
        if mag <= 10 then 
            local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(v.UpperTorso.Position)
            script.Parent.Visible = true
            script.Parent.Position = UDim2.new(0,WSP.X,0,WSP.Y)
            script.Parent.TextLabel.Text = "To Open The Shop"..v.Name
        end
    end
end

Then , Inside the NPCs Folder we have the Npc, inside the NPC i've put : -The ShopGUI (it's the name of the gui i've put inside the npc.) inside i've put just a normal TextButton for Close the GUI with the script inside :

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent:Destroy()
end)

-and this Normal Script :

script.Parent.NPCTalk.OnServerEvent:connect(function(player)
    if not player.PlayerGui:FindFirstChild("ShopGUI") then
        local gui = script.Parent:FindFirstChild("ShopGUI"):Clone()
        gui.Parent = player.PlayerGui 
    end
end)

The Problem is , that i've checked all the scripts and i can't find the actual problem! I have no idea why this don't work!

0
Try removing line 30 Leamir 3138 — 5y
0
why are you destroying script.Parent.Parent HappyTimIsHim 652 — 5y
0
that script it's for closing the shop gui. so when i click the button inside the ShopGui that should close. AlexAecid -12 — 5y

Answer this question