Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The part could not find and i don't know why ? also all is right

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)

6 comments

0

what do you mean by that? Could you show us your Output?

0

local gp = script.Parent.GrabPower and it is there

0

its says its not a member and it is

0

Still not specific. Could you show us your actual code? In the Lua format. Thanks.

0

you probably should write local gp = script.Parent:WaitForChild("GrabPower")

0

oh thank you its works

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.