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

Welds are not welding to Player. What is wrong with this script? [SOLVED]

Asked by 3 years ago
Edited 3 years ago

My welds don't do anything when I create them in a script but when I change their properties in the explorer while playing the game, they work perfectly. What do I need to do in order to make this work because I am very confused. It outputs no errors and the script runs perfectly creating both welds and assigning their properties.

function TestService:Spawn(Player, Weapon)
    if Weapon ~= Items.IDArray[Weapon] then
        game.ReplicatedStorage.SuccessMessage:FireClient(Player, "? Successfully found "..Weapon.." with ID "..Items.IDArray[Weapon].ID)

        -- Welding
        local WeaponSaid = game.ReplicatedStorage[Weapon]
        local Fake = WeaponSaid:Clone()
        Fake.Parent = game.Workspace[Player.Name]
        local WeldC0 = Instance.new("Weld", Fake.Model.Handle)
        local WeldC1 = Instance.new("Weld", game.Workspace[Player.Name]["Right Arm"])
        WeldC0.Name = "FakeHandle" 
        WeldC1.Name = "PlayerHandle"

        wait(0.5)
        Fake:SetPrimaryPartCFrame(CFrame.new(game.Workspace[Player.Name]["Right Arm"].Position))
        WeldC0.Part0 = WeaponSaid.Model.Handle
        WeldC0.Part1 = game.Workspace[Player.Name]["Right Arm"]

        wait(0.5)
        Fake:SetPrimaryPartCFrame(CFrame.new(game.Workspace[Player.Name]["Right Arm"].Position))
        WeldC1.Part0 = WeaponSaid.Model.Handle
        WeldC1.Part1 = game.Workspace[Player.Name]["Right Arm"]

        Fake:SetPrimaryPartCFrame(CFrame.new(game.Workspace[Player.Name]["Right Arm"].Position))
    else
        game.ReplicatedStorage.ErrorMessage:FireClient(Player, "? Sorry, I couldn't find "..Weapon.." in my Array!")
    end
end
0
Also tried debug info and it prints fine. iiMxtt_Destinyii 62 — 3y
0
Try WeldConstraint instead of Weld ezkatka1 50 — 3y
0
also here at line 16 you are setting Part0 to WeaponSaid.Model.Handle ( thats inside replicated storage tho try setting it for Fake.Model.Handle) ezkatka1 50 — 3y
0
Alright, thanks. I'll try that. iiMxtt_Destinyii 62 — 3y
View all comments (3 more)
0
Yep, that has fixed it thanks. iiMxtt_Destinyii 62 — 3y
0
Okey you can make it answered down below so poeple know its fixed! ezkatka1 50 — 3y
0
Also if you can give me Reputation i would appreciate it! ezkatka1 50 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

Answered!

Ad

Answer this question