-
What do you want to achieve? Keep it simple and clear!
I want to make that if you are holding a pickaxe tool you can activate a proximity prompt -
What is the issue? Include screenshots / videos if possible!
its says "attempt to index nil with find first child -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried looking for people with similar problems in the devforum but there are none
here is the code
local prox = script.Parent
local rs = game:GetService("ReplicatedStorage")
local crystal = rs:WaitForChild("Crystal")
local isCooldown = false
wait(10)
local playerData = require(game.ServerScriptService.PlayerData)
local player = playerData.GetPlayer()
prox.Triggered:Connect(function(player)
isCooldown = true
prox.Enabled = false
script.Parent.Parent.Transparency = 1
script.Parent.Parent.CanCollide = false
crystal:Clone().Parent = player.Backpack
wait(5)
isCooldown = false
prox.Enabled = true
script.Parent.Parent.Transparency = 0
script.Parent.Parent.CanCollide = true
end)
while wait(1) do
local pickaxe = player.Character:FindFirstChild("Pickaxe") -- here is the error
if pickaxe then
if isCooldown ~= true then
prox.Enabled = true
else
prox.Enabled = false
end
end
end
i use a module script to get the player from the server side, i have also other scripts that uses the module script but they are working perfectly fine. i tried printing the character and it also works fine. its only here that there is a problem. also just to let you know this is a singleplayer game, so the max people in each server is 1.