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

How to make a part fixed on my body part when I click a press a key ?

2 answers

local ball = script.Parent
local hand = put the location of hand here tbh i have no idea how to
while true do
	wait()
	local handposy = hand.Position.Y
	ball.Position = hand.Position - Vector3.new(0,handposy / 2,0)
end

no idea if its gonna work and idk if this is what u want to do if it works then accept

7 comments

0

Not work :()

0

whats the error

0

oh wait i forgot one thing im gonna edit the script

0

try now and tell me the errors if it doesnt

0

Seriously, weld it

0

oh ye lol

0

pls add in soon

You first need to use userInputService.

local UIS = game:GetService("UserInputService")
local key = Enum.KeyCode.Q --//Use whatever key you want them to click

local on = false

local ball

UIS.InputBegan:Connect(function(input, gameProcessed)

	on = not on
	
	if on == false then
		local player = game.Players.LocalPlayer
		if input.KeyCode == key then
			local OriginalBall = game:GetService("ReplicatedStorage").Ball
			ball = OriginalBall:Clone()
			ball.Parent = workspace
			local char = player.Character or player.CharacterAdded:Wait()
			ball.CFrame = char.LeftHand.CFrame
			local newWeld = Instance.new("Weld")
			newWeld.Parent = ball
			newWeld.Part0 = char.LeftHand
			newWeld.Part1 = ball
		end
	elseif on == true then
		if input.KeyCode == key then
			ball:Destroy()
		end
	end
end)

Say the OriginalBall variable is in ReplicatedStorage so you clone that to the workspace

I'm not sure if this will work or not as I haven't tested. But sorry if it didn't work, I tried my best.

3 comments

0

how to know ball position ??

0

Ur script is working but how do I press that same key to turn it off?

0

I edited my script, have a look now

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