I’ve been trying for a long time to a weld one part to my players back. I’ve tried to use qPerfectionWeld script by Quenty to achieve this but I want to only load the script into my player when the game is running.
The script works when I put it in something before the game runs but not when the player clicks a button.
I don’t know if there’s a proper way to load the script into the game or it has something to do with the script itself.
Here is a video of my character dieing in the game. I have the qPerfectionWeld script in the character model of my player. I don’t know what I am doing incorrect.
I’ve looked on Youtube, I’ve looked on Devforum. There are posts similar to my post but I didn’t see any exactly like mine.
I have this code that I want when a gui button is clicked then a part is inserted when I click the button and the part gets welded to character from the weld script. I suppose that the qPerfection weld script would automatically update any child added to the character model.
-- This is an example Lua code block
local part = game:GetService("ReplicatedStorage"):WaitForChild("Part")
local btnEvt = game:GetService("ReplicatedStorage"):("BtnEvt")
btnEvt.OnServerEvent:Connect(function(player)
if player.Character then
local partCopy = part:Clone()
partCopy.Parent = player.Character
end
end)
If I could have explained myself any better let me know. Any help would be great.
local a = Instance.new(“Attachment”, rbx)
local b = Instance.new(“Attachment”, rbx)
local c = Instance.new(“Attachment”, rbx)
local d = Instance.new(“Attachment”, rbx)
local w = Instance.new(“Weld”, rbx)
w.Part0, w.Part1 = rbx, rbx
w.C0, w.C1 = c0, c1
local function UpdateWeld(rbx, c0, c1)
local a, b, c, d = a, b, c, d
a.Position = c0.p
b.Position = c1.p
c0 = CFrame.new(a.Position)
c1 = CFrame.new(b.Position)
w.C0, w.C1 = c0, c1
end
local function GetWeld(rbx)
local a, b, c, d = a, b, c, d
a.Position = rbx.CFrame.p
b.Position = rbx.Parent.CFrame:toObjectSpace(rbx.CFrame).p
local c0 = CFrame.new(a.Position)
local c1 = CFrame.new(b.Position)
return c0, c1
end
local function UpdateWeld()
local c0, c1 = GetWeld(rbx)
UpdateWeld(rbx, c0, c1)
end
local function NoOutliers(t, d)
local n = #t
local m = math.floor(n / 2)
table.sort(t)
if n >= 3 then
local t1 = t[1]
local t2 = t[n]
local tm = t[m]
if t1 + d >= tm or tm >= t2 - d then
t[1] = tm
t[n] = t