UIS = game:GetService("UserInputService")
local grabbed_object = nil
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local mt = mouse.Target
funcs = script.Parent.surface
local gp = script.Parent.GrabPower ****this could not find
local gr = script.Parent.GrabRange
local tool = script.Parent
UIS.InputBegan:Connect(function(mouse)
if mouse.KeyCode == Enum.KeyCode.E then
if grabbed_object == nil and (mt.Position - tool.Handle.Position).magnitude < gr.Value then
if mt.Parent:FindFirstChild("CanGrab") then
if mt:getMass() > gp.Value then return end
mt.CFrame = player.Head.Handle.CFrame * CFrame.new(0,6,0)
local w = funcs.weld(mt, player.tool.Handle)
w.Name = "Grab"
grabbed_object = mt
elseif grabbed_object then
grabbed_object.Grab:Destroy()
grabbed_object.Velocity = tool.Parent.Torso.CFrame.lookVector*100
grabbed_object = nil
end
end
end
end)
COMMUNITY QUESTION
The part could not find and i don't know why ? also all is right
1 answer
I suggest using the WaitForChild function as it wait for an action to be done. Also please put your code in a code block.
UIS = game:GetService("UserInputService")
local grabbed_object = nil
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local mt = mouse.Target
funcs = script.Parent.surface
local gp = script.Parent:WaitForChild("GrabPower")
local gr = script.Parent.GrabRange
local tool = script.Parent
UIS.InputBegan:Connect(function(mouse)
if mouse.KeyCode == Enum.KeyCode.E then
if grabbed_object == nil and (mt.Position - tool.Handle.Position).magnitude < gr.Value then
if mt.Parent:FindFirstChild("CanGrab") then
if mt:getMass() > gp.Value then
return end
mt.CFrame = player.Head.Handle.CFrame * CFrame.new(0,6,0)
local w = funcs.weld(mt, player.tool.Handle)
w.Name = "Grab"
grabbed_object = mt elseif grabbed_object then grabbed_object.Grab:Destroy() grabbed_object.Velocity = tool.Parent.Torso.CFrame.lookVector*100 grabbed_object = nil end end end end)
1 comment
0
The answer was already solved in the comments.
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
what do you mean by that? Could you show us your Output?
local gp = script.Parent.GrabPower and it is there
its says its not a member and it is
Still not specific. Could you show us your actual code? In the Lua format. Thanks.
you probably should write local gp = script.Parent:WaitForChild("GrabPower")
oh thank you its works