ServerScriptService.OreHandler:15: attempt to call missing method 'GetChildren' of string

What I’m trying to do is change the variable by the name of “OreStatus” to the ore model that has been recently hit, and well, so far it isn’t working as great as I want it to unfortunately. I’ve tried moving things around, but it constantly spits out errors and I’m rather confused. Any help would be appreciated! Below you’ll find the script that I’ve made, rather simple so it shouldn’t be too difficult to debug.

local Tool = script.Parent
local Handle = Tool.Handle
local cooldown = 3
local on_cooldown = false
local replicatedStorage = game:GetService("ReplicatedStorage")
local OreTouchedEvent = replicatedStorage.OreTouchedEvent
local OreStatus = nil

Handle.Touched:Connect(function(hit)
	if hit.Parent:IsA("Model") and hit.Parent.Name == "Rock" and not on_cooldown then 
		OreStatus = hit.Parent.Name
		on_cooldown = true 
		task.wait(cooldown) 
		on_cooldown = false 
		OreTouchedEvent:FireServer(OreStatus)
	elseif hit.Parent:IsA("Model") and hit.Parent.Name == "IronOre" and not on_cooldown then 
		OreStatus = hit.Parent.Name
		on_cooldown = true 
		task.wait(cooldown) 
		on_cooldown = false
		OreTouchedEvent:FireServer(OreStatus)
	elseif hit.Parent:IsA("Model") and hit.Parent.Name == "GoldOre" and not on_cooldown then 
		OreStatus = hit.Parent.Name
		on_cooldown = true 
		task.wait(cooldown) 
		on_cooldown = false
		OreTouchedEvent:FireServer(OreStatus)
	elseif hit.Parent:IsA("Model") and hit.Parent.Name == "AzureOre" and not on_cooldown then 
		OreStatus = hit.Parent.Name
		on_cooldown = true 
		task.wait(cooldown) 
		on_cooldown = false 
		OreTouchedEvent:FireServer(OreStatus)
	end
end)

If the title is the error message then this isn’t the script it’s happening in. It sounds like maybe you want to send the object and not its name, though, which is a string.

It’s happening in the serverscript, my fault!

OreTouchedEvent.OnServerEvent:Connect(function(player, Ore)
	local char = player.Character
	local hum = char:FindFirstChildOfClass("Humanoid")
	if not debounce then
	if hum then
		local pickaxe = char:WaitForChild("Pickaxe")
		if pickaxe then
			for _, v  in(Ore:GetChildren()) do
				if v:IsA("BasePart") and v.Name ~= "Hitbox" then
					v.Transparency += 0.25
						if v.Transparency == 1 and v.Name == "Detect" then
							if Ore.Name == "Rock" then
								print("Rock!")
							elseif Ore.Name == "IronOre" then
								print("iron!")
							elseif Ore.Name == "AzureOre" then
								print("Azure Ore!")
							end
						end
						end
					end
				debounce = true
				task.wait(3)
				debounce = false
			end
		end				
	end
end)

Specifically this line here

for _, v  in(Ore:GetChildren()) do

Ore is a string because you’re passing OreStatus = hit.Parent.Name, maybe you want to just use hit.Parent instead.

1 Like

This works, thank you for your assistance!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.