#Sheathing and unsheathing mechanic?

1 messages · Page 1 of 1 (latest)

trim elbow
#

How do I script a sheathing and unsheathing mechanic? I want the sheath to be attached to the player's back/leg and when the player presses a certain key (let's say e) the sword gets taken out of the sheathe and into the players hand. I don't care about making an animation rn but I just want to know how I can do it.

grave cargo
#

Its complixated 👍

coarse patrolBOT
#

studio** You are now Level 3! **studio

marsh scarab
shell rover
#

Pretty complicated

marsh scarab
#

"thanks for making this script for me now give me 500 bobux"

shell rover
#

It’s not 500

#

It’s like 150

marsh scarab
#

do you even realize wht you're saying

shell rover
#

?

marsh scarab
#

do you want to pay people to make this or do you want people to pay you to make this

shell rover
#

The second one

marsh scarab
#

because nobody's going to spend money on making something for you

shell rover
#

Why would I want this, if I replied to the forum

#

?

marsh scarab
#

you don't make any sense at all vro

shell rover
#

You can’t even spell “bro” correctly js stop talking to me

marsh scarab
#

wait

#

i'm so f**king dumb i thought you were op

#

off to hang myself

shell rover
marsh scarab
shell rover
#

You meant to use “,”

#

The first letter of your sentence is to be capitalized.

marsh scarab
#

🤓☝️

#

anyway isn't this just animation:Play()?

twin granite
#

@trim elbow I mean it is complicated enough where if we walk u through step by step it would probably be a commission

coarse patrolBOT
#

studio** You are now Level 14! **studio

twin granite
#

But I can tell u some things

#

Usually when you “unseathe” the weapon gets inserted into a right hand or ur right arm with a module telling the weld where to go for specific weapons/models

trim elbow
#

Oh

twin granite
#

Same thing for sheathing but it’s just cloned an welded onto ur torso

trim elbow
#

What I'm having trouble with mostly is sheathing

#

Welding**

shell rover
#

The scripting or the animations

coarse patrolBOT
#

studio** You are now Level 3! **studio

trim elbow
shell rover
#

Any particular bugs ?

#

With the script

trim elbow
#

Idk how to weld it

#

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

-- Wait for character to load
player.CharacterAdded:Connect(function(c)
char = c
end)

-- Get sword model from workspace
local swordModel = workspace:WaitForChild("Zanpakuto")

-- Clone the sword
local sword = swordModel:Clone()
sword.Name = "VisualSword"
sword.Anchored = false
sword.CanCollide = false
sword.Parent = char

-- State flag
local isSheathed = true

-- Attach function
local function attachSword(partName, position, rotation)
-- Remove any existing welds
for _, child in ipairs(sword:GetChildren()) do
if child:IsA("WeldConstraint") then
child:Destroy()
end
end

-- Weld to the player
local weld = Instance.new("WeldConstraint")
sword.CFrame = char[partName].CFrame * CFrame.new(position) * CFrame.Angles(unpack(rotation))
sword:SetPrimaryPartCFrame(sword.CFrame)
weld.Part0 = sword
weld.Part1 = char[partName]
weld.Parent = sword

end

-- Toggle sword position
local function toggleSword()
if isSheathed then
-- Put in hand
attachSword("RightHand", Vector3.new(0, 0, 0), {0, 0, 0})
else
-- Put on back
attachSword("UpperTorso", Vector3.new(0, 1, 0.5), {math.rad(90), 0, 0})
end
isSheathed = not isSheathed
end

-- Key press handler
UserInputService.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.R then
toggleSword()
end
end)

#

I susd this

#

Used*

shell rover
#

It seems your using weldconstraint

trim elbow
#

Yea

shell rover
#

You would need to use Motor6D or Weld

twin granite
#

I’d use welds and tediously find the perfect cframe for it

#

Normal welds

shell rover
#

if you want to control position n stuff

shell rover
trim elbow
#

So do I just change the "WeldConstraint" into just "Weld"?

coarse patrolBOT
#

studio** You are now Level 2! **studio

shell rover
#

Does the sword have a primary part

#

That would make this easier

grave cargo
trim elbow
#

It's just a part

#

Like a long stick

#

As a place holder

marsh scarab
trim elbow
#

I'm so confused ngl

#

I should probably just learn scripting from the basics

#

And then try to tackle this later

grave cargo
grave cargo
#

Just learn how to code in general then use ai to help you understand scripting in roblox specifically

#

Codeacademy or smth

#

Its not an easy process

trim elbow
#

Ik

#

How long would it take?

marsh scarab
#

listen man, you won't get far if your whole idea is you wake up one day and go "yeah i wanna remake the strongest battlegrounds"

#

there's no easy way out of coding

#

if you really want to make something you'll actually spend time learning to code

#

sorry if that's harsh, but it's true

trim elbow
marsh scarab
#

not how that works

trim elbow
#

I'm just curious how long it takes to learn scripting enough to be able to start making stuff like this

marsh scarab
#

trying to make a big project, right off the bat, won't help you

trim elbow
#

Like to be proficient

#

Ig

marsh scarab
#

good question, i don't have that much experience

#

i'm not a pro scripter but i'm alright

#

so i wouldn't know

trim elbow
#

How long did it take you?

marsh scarab
#

~6 months?

#

not 100% sure

trim elbow
#

Oh

#

That's less time than I expected

marsh scarab
#

i reccomend brawldev tutorial to get started

grave cargo
#

Learn python and then just start scripting with the help of ai

twin granite
#

Don’t rely on ai pls

trim elbow
trim elbow
twin granite
#

I mean ai can teach you syntax ig

#

I’m saying don’t rely on it to script for u

#

Some dude taught me how to script

#

It took like 2 months of teaching then 4 more to put it in practice

#

Then after that ur on ur own

#

You gotta find and research services and functions built into roblox

#

Either naturally or if u wanna learn something new

trim elbow
#

Oh

spice vortex
trim elbow
coarse patrolBOT
#

studio** You are now Level 3! **studio