Hi!
I want this script to check if there is a value inside the tool.
I have already tried to rewrite the script several times and wasted my 3 hours on it. The result is that no value is found, even though the value exists there.
If anyone could tell me what I’m doing wrong?
Plus, it’s just one of the scripts I’ve tried to write, but no matter how I combine it, it doesn’t find value.
script.Parent.FunctionPart.CutPrompt.TriggerEnded:Connect(function(plr)
local tool = plr.Character:FindFirstAncestorOfClass("Tool")
local IsCutter = tool:WaitForChild("IsCutterPart")
if IsCutter then
print("Cut")
end
end)
Tool would be a descendant not an ancestor of the character (assuming it’s equipped). So you should change the FindFirstAncestorOfClass to find the first child/descendant.
script.Parent.FunctionPart.CutPrompt.TriggerEnded:Connect(function(plr)
local tool
for i,v in ipairs(plr.Character:GetChildren()) do
if v:IsA("Tool") then
tool = v
break
end
end
local IsCutter = tool:WaitForChild("IsCutterPart")
if IsCutter then
print("Cut")
end
end)
script.Parent.FunctionPart.CutPrompt.TriggerEnded:Connect(function(plr)
local tool = plr.Character:WaitForChild("Tool")
local IsCutter = tool:WaitForChild("IsCutterPart")
if IsCutter then
print("Cut")
end
end)
You must wait until tool is existant/equipped, or tool would be nil at the time of setting it.