#Trying to create a Shop Gui where players can buy tools from...

13 messages · Page 1 of 1 (latest)

wraith garnet
#

Hi,

I'm trying to code a script under the ShopGui's Frame, but there seem to be a problem with finding the TextButton in the MainFrame object. Errormessage displayed below

local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character.Humanoid
local BuyToolEvent = game.ReplicatedStorage.BuyToolEvent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
-- GUI Variables:
local MainFrame = game:WaitForChild(StarterGui.ScreenGui.Frame)
MainFrame.Visible = false
local CloseButton = MainFrame.TextButton


local buy1 = game.MainFrame.Buy1
local buy2 = game.MainFrame.Buy2
local buy3 = game.MainFrame.Buy3


-- Shop Parts:
local ShopActivator = game.Workspace.ShopActivator
local resetPart = game.Workspace.ShopResetTeleport


local function OpenShop(Hit)
    -- Since you are working on a local script, I think you can verify the Player like this:
    if PlayerService:GetPlayerFromCharacter(Hit.Parent) == Player then
        MainFrame.Visible = true
        Humanoid.WalkSpeed = 0
    end
end

local function CloseShop()
    MainFrame.Visible = false
    Humanoid.WalkSpeed = 16
    HumanoidRootPart.CFrame = resetPart.CFrame
end


local function buytool1()
    local tool = ReplicatedStorage.SuperGravityCoil
    BuyToolEvent:FireServer(tool)
end


local function buytool2()
    local tool = ReplicatedStorage.Bat
    BuyToolEvent:FireServer(tool)
end


local function buytool3()
    local tool = ReplicatedStorage["Minecraft Diamond Sword"]
    BuyToolEvent:FireServer(tool)
end
    
    

ShopActivator.Touched:Connect(OpenShop)
CloseButton.MouseButton1Click:Connect(CloseShop)
buy1.MouseButton1Click:Connect(buytool1)
buy2.MouseButton1Click:Connect(buytool2)
buy3.MouseButton1Click:Connect(buytool3)
#

errorMessage: The current identity (2) cannot Class security check (lacking permission 6) - Client - LocalScript:11

grand cedar
#

waitforchild takes a string not an instance

wraith garnet
#

ohh thx I'll check

#

hmm idk, when you make it a string it just result in infinite yield

grand cedar
#

then its not there

#

not inside of game anyways

#

which is weird to waitforchild on anyways

wraith garnet
#

idk, it certainly is in the game

#

i checked

#

textbutton is under the frame and frame is under screenGui

hasty hound
wraith garnet
#

Btw i solved it