Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isnt my Part Detecting the Players Position?

Asked by 7 years ago
Edited 7 years ago

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.

0
Accept my answer. Void_Frost 571 — 6y

2 answers

Log in to vote
0
Answered by
farrizbb 465 Moderation Voter
7 years ago
Edited 7 years ago

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
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. OpticalAce 49 — 7y
0
hmm farrizbb 465 — 7y
0
No need to be patronizing, he's learning. Azarth 3141 — 7y
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. OpticalAce 49 — 7y
View all comments (2 more)
0
what part farrizbb 465 — 7y
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. OpticalAce 49 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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

Answer this question