Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

You have a typo, do

local remoteEvent = ReplicatedStore:WaitForChild('BuyTool')

1 comment

0

didn t workit

This discussion is preserved as it was. New answers, comments, and votes are closed.