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

attempt to index nil with 'WaitForChild' how can i repair this?

Asked by 2 years ago
Edited 2 years ago
local open = game.Workspace.openPart
local close = game.Workspace.closePart
local frame = script.Parent
local closeButton = frame.closeButton
local buy_1 = frame.buy1
local buy_2 = frame.buy2
local buy_3 = frame.buy3

local ReplicatedStore = game:GetService('ReplicatedStorage')
local remoteEvent = Replicatedstorage:WaitForChild('BuyTool')

frame.Visible = false

local function shopMenu(otherPart)
    local player = game.Players:FindFirstChild(otherPart.Parent.Name)
    if player then
        player.PlayerGui.ScreenGui.shop.Visible = true
        player.Character.Humanoid.WalkSpeed = 0
    end
end

local function closeMenu()
    local player = game.Players.LocalPlayer
    player.PlayerGui.ScreenGui.shop.Visible = false
    player.Character.HumanoidRootPart.CFrame = CFrame.new(close.Position.X,close.Position.Y + 3,close.Position.Z)
    player.Character.Humanoid.WalkSpeed = 16
end

local function buyTool1()
    local tool = replicatedStorage.Shopitems.Water
    remoteEvent:FireServer(tool)
end


open.Touched:Connect(shopMenu)
closeButton.MouseButton1Click:Connect(closeMenu)
buy_1.MouseButton1Click:Connect(buyTool1)
--buy_2.MouseButton1Click:Connect()
--buy_3.MouseButton1Click:Connect()

1 answer

Log in to vote
2
Answered by 2 years ago

You have a typo, do

local remoteEvent = ReplicatedStore:WaitForChild('BuyTool')
0
didn t workit efecan852 2 — 2y
Ad

Answer this question