hi, i currently have a script but i only want it to work on a certain part. right now i have a donation board in my game but because this works on everything, the donation board doesnt work. again, im just looking to make it so it it only works on one part. if you can help at all please let me know!
here is the LocalScript in StarterCharacterScripts
local CAS = game:GetService("ContextActionService")
local GrabObject = nil
local GrabStart = false
local Dragger = nil
local player = game.Players.LocalPlayer
local character = player.Character
local mouse = player:GetMouse()
local camera = game.Workspace.CurrentCamera
function Grab(actionName, UserInputState, InputObject)
if actionName == "Grab" then
if UserInputState == Enum.UserInputState.Begin then
local Magnitude = (mouse.Hit.Position - character.Head.CFrame.Position).magnitude
if Magnitude < 10 then
if mouse.Target then
GrabObject = mouse.Target
GrabStart = true
local DragBall = createDragBall()
DragBall.CFrame = mouse.Hit
Dragger = DragBall
mouse.TargetFilter = GrabObject
local DragBallWeld = weldBetween(DragBall,GrabObject)
addMover(DragBall)
while Dragger do
local cf = CFrame.new(character.Head.Position, mouse.Hit.Position)
Dragger.Mover.Position = (cf + (cf.LookVector * 10)).Position
Dragger.RotMover.CFrame = camera.CFrame * CFrame.Angles(Dragger.RotOffset.Value.X,Dragger.RotOffset.Value.Y, Dragger.RotOffset.Value.Z)
wait()
end
mouse.TargetFilter = nil
end
end
elseif UserInputState == Enum.UserInputState.End then
GrabObject = nil
GrabStart = false
if Dragger then
Dragger:Destroy()
Dragger = nil
end
end
end
end
function weldBetween(a, b)
local weld = Instance.new("ManualWeld", a)
weld.C0 = a.CFrame:inverse() * b.CFrame
weld.Part0 = a
weld.Part1 = b
return weld
end
function addMover(part)
local newMover = Instance.new("BodyPosition")
newMover.Parent = part
newMover.MaxForce = Vector3.new(40000,40000,40000)
newMover.P = 40000
newMover.D = 1000
newMover.Position = part.Position
newMover.Name = "Mover"
local newRot = Instance.new("BodyGyro")
newRot.Parent = part
newRot.MaxTorque = Vector3.new(3000,3000,3000)
newRot.P = 3000
newRot.D = 500
newRot.CFrame = game.Workspace.CurrentCamera.CFrame
newRot.Name = "RotMover"
local RotOffset = Instance.new("CFrameValue")
RotOffset.Name = "RotOffset"
RotOffset.Parent = part
end
function createDragBall()
local DragBall = Instance.new("Part")
DragBall.Size = Vector3.new(.2,.2,.2)
DragBall.Shape = "Ball"
DragBall.Name = "DragBall"
DragBall.Parent = workspace
DragBall.Transparency = 1
return DragBall
end
CAS:BindAction("Grab", Grab, false, Enum.UserInputType.MouseButton1)