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()