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

Why isnt my Part Detecting the Players Position?

So ive been trying to make a script where when a player presses down the 'F' Key, The player spawns in a part. I have been trying to tell the part to position to the Right Arm in the players model but everytime I call it, it spawns to the center of the map as if I didnt call it to the players Right Arm.

vPlayer = game.Players.LocalPlayer
local character = vPlayer.Character
local _RightArm = character:FindFirstChild("Right Arm")

function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.F and _RightArm then
		
local part = Instance.new('Part')
part.Name = 'Crow'
part:Clone().Parent = character
part.CFrame = _RightArm.CFrame
	end
end
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

Im not sure why it isnt detecting the RightArms position, any help would be much appreciated

This may help, But if any of you are familiar with Shinobi Life on roblox, I am basically trying to make it so when you press a key it does an action, in my case its spawning a brick in my hand.

1 comment

0

Accept my answer.

2 answers

Okay it seems like you aren't familiar with LUA so let me fill you in on some knowledge. You can't just do Part.Position = Right Arm why would you think that'd work.Instead do the following:Use Vector3 or do what is done below;Use CFrame instead(if you choose the first one you suck).

Part.Position = RightArm.Position
Part.CFrame = RightArm.CFrame

6 comments

0

I have tried using CFrame to position it to the players Right Arm, it gives me no errors but it doesn't spawn the part at the position of my hand, it just spawns in the center of the baseplate acting as if it has no position to go to, that is what the main issue is.

0

hmm

0

No need to be patronizing, he's learning.

0

Thanks! No worries though, Do you happen to know what's up with the script? I still haven't been able to figure it out.

0

what part

0

Even though there are no errors, the CFrame of the cloned part still doesn't go to the players hand, it goes to the center of the baseplate.

UserInputService wont work if it isn't in a localscript. Otherwise, I don't see anything wrong.

This discussion is preserved as it was. New answers, comments, and votes are closed.