Do make sure that there isn’t another part named Handle inside of the plateModel
After re-reading the error I noticed that it’s for the Fries Tool, not the plateModel inside of Workspace
The Fries Tool doesn’t have a proximity prompt inside of its handle, but this is most likely intentional. The easiest solution would be to do this:
local proxPrompt = script.Parent.Handle:FindFirstChild("ProximityPrompt")
local plateModel = script.Parent
if proxPrompt then
proxPrompt.Triggered:Connect(function(player)
print("Proximity prompt triggered")
if player then
print("Player found:", player.Name)
local character = player.Character
if character then
print("Character found for player:", player.Name)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
print("Humanoid found for player:", player.Name)
local activatedTool = nil
-- Connect the Activated event outside the loop
local backpack = character:GetChildren()
for _, tool in ipairs(backpack) do
if tool:IsA("Tool") then
print("Connecting Activated event for tool:", tool.Name)
if tool.Activated then
activatedTool = tool
break
end
end
end
-- Wait for the Activated event to be triggered
wait(0.1)
-- Check if the activated tool is equipped
if activatedTool and activatedTool.Parent == character then
print("Activated and equipped tool found for player:", player.Name)
-- Clone the plate model under the activated and equipped tool
local plateClone = plateModel:Clone()
plateClone.Handle.ProximityPrompt:Destroy()
plateClone.Parent = activatedTool
plateClone:SetPrimaryPartCFrame(activatedTool.Handle.CFrame * CFrame.new(0, -1, 0)) -- Adjust the position under the tool
print("Plate cloned and positioned under activated and equipped tool for player:", player.Name)
for _, instance in plateClone:GetDescendants() do
if instance:IsA("BasePart") then
local weld = Instance.new("WeldConstraint")
weld.Part0 = activatedTool.Handle
weld.Part1 = instance
weld.Parent = activatedTool
instance.Anchored = false
end
end
else
print("No activated and equipped tool found for player:", player.Name)
end
else
print("No humanoid found for player:", player.Name)
end
else
print("No character found for player:", player.Name)
end
else
print("No player found")
end
end)
end
Wow, this worked! How did you manage to do it? I’ll mark it as the solution, and thank you so much for this tremendous help, really.
By the way, thank you all very much for the help on the post.
The script is now checking if the handle contains the prompt before running the rest of its code, which fixed the issue causing the error to occur
Now the script will only work when a prompt is found in the handle, as the original intent was
Thank you very much for the clarification and your comments, they really help me a lot in my learning. By the way, one last thing to ask, how could I set a specific time for the original model to be invisible for 5 seconds after cloning and then become visible again?
Oh nvm i already did thanks you so much
local proxPrompt = script.Parent.Handle:FindFirstChild("ProximityPrompt")
local plateModel = script.Parent
local invisibilityDuration = 5
if proxPrompt then
proxPrompt.Triggered:Connect(function(player)
print("Proximity prompt triggered")
if player then
print("Player found:", player.Name)
local character = player.Character
if character then
print("Character found for player:", player.Name)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
print("Humanoid found for player:", player.Name)
local activatedTool = nil
-- Connect the Activated event outside the loop
local backpack = character:GetChildren()
for _, tool in ipairs(backpack) do
if tool:IsA("Tool") then
print("Connecting Activated event for tool:", tool.Name)
if tool.Activated then
activatedTool = tool
break
end
end
end
-- Wait for the Activated event to be triggered
wait(0.1)
-- Check if the activated tool is equipped
if activatedTool and activatedTool.Parent == character then
print("Activated and equipped tool found for player:", player.Name)
-- Clone the plate model under the activated and equipped tool
local plateClone = plateModel:Clone()
plateClone.Handle.ProximityPrompt:Destroy()
plateClone.Parent = activatedTool
plateClone:SetPrimaryPartCFrame(activatedTool.Handle.CFrame * CFrame.new(0, -1, 0)) -- Adjust the position under the tool
print("Plate cloned and positioned under activated and equipped tool for player:", player.Name)
for _, instance in ipairs(plateClone:GetDescendants()) do
if instance:IsA("BasePart") then
local weld = Instance.new("WeldConstraint")
weld.Part0 = activatedTool.Handle
weld.Part1 = instance
weld.Parent = activatedTool
instance.Anchored = false
end
end
-- Make the original plate model invisible
for _, instance in ipairs(plateModel:GetDescendants()) do
if instance:IsA("BasePart") then
instance.Transparency = 1
end
end
-- Set a timer to make the original plate model visible again after a certain duration
wait(invisibilityDuration)
for _, instance in ipairs(plateModel:GetDescendants()) do
if instance:IsA("BasePart") then
instance.Transparency = 0
end
end
else
print("No activated and equipped tool found for player:", player.Name)
end
else
print("No humanoid found for player:", player.Name)
end
else
print("No character found for player:", player.Name)
end
else
print("No player found")
end
end)
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.