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

Whats wrong with my Replicated Storage Script?

Asked by
neoG457 315 Moderation Voter
9 years ago
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(key)
if key == "p" then

local RinkakuModel = game.ReplicatedStorage.WorkspaceRinkakuModel:Clone() --Assuming the model is now in ReplicatedStorage
local primary_part = RinkakuModel.Primary -- Since this is used a lot, let's store it in a temporary variable
RinkakuModel.PrimaryPart = primary_part

local w = Instance.new('Weld')
w.Part0 = primary_part
w.Part1 = Player.Character.Torso
w.C0 = CFrame.new(0, 10, 0)
w.Parent = primary_part

primary_part.Anchored  = true -- Not sure if you still need to anchor it, if not you can leave it out.
for index = 1, 15 do
    local part = RinkakuModel["Part" .. index] -- This will generate Part1 till Part15
    local weld = Instance.new("Weld")
    weld.Part0 = primary_part
    weld.Part1 = part
    weld.C1 = part.CFrame:toObjectSpace(primary_part.CFrame)
    weld.Parent = primary_part
    part.Anchored = true -- Same here with the anchoring
    return weld
end


RinkakuModel:SetPrimaryPartCFrame(Player.Character.Torso.CFrame * CFrame.new(0, 10, 0))-- It's probably a good idea to use SetPrimaryPartCFrame before parenting it.
RinkakuModel.Parent = workspace

RinkakuModel:MakeJoints()-- You don't need to use MakeJoints because you did that manually
RinkakuModel.Name = Player.Name

end
end)

It should copy the model from replicated storage and weld its primary part onto my torso along with the other 15 parts in the model. However it isn't doing that and the output isn't saying anything either. This is a local script in starterpack, please help.

1
Can you PM a link to the model of this script and the RinkakuModel? Testing with welds requires actually being able to test the welds. adark 5487 — 9y
0
Unfortunately no nothing appears whatsoever and I cant PM you it because of your privacy settings so here: http://www.roblox.com/WorkspaceRinkakuModel-item?id=231758963 neoG457 315 — 9y
1
What? http://puu.sh/gVd7m/7c3c4b2453.png (Also, sorry for the lack of reply, my Notifications aren't updating properly. adark 5487 — 9y
1
Please check https://scriptinghelpers.org/questions/16112/help-me-move-with-my-model#19350 again. `return weld` is a mistake. Also, either switch Part0 and Part1 of `w`, or invert w.C0; although you need to change that anyway to get it in the right position. I also recommend you set CanCollide to false for the parts in the model. Good luck. noliCAIKS 210 — 9y
0
Thanks. neoG457 315 — 9y

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Here is your fixed code:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(key)
    if key == "p" then
        if Player.Character:FindFirstChild("WorkspaceRinkakuModel") then return end

        local RinkakuModel = game.ReplicatedStorage.WorkspaceRinkakuModel:Clone()
        local primary_part = RinkakuModel.Primary
        RinkakuModel.PrimaryPart = primary_part

        local w = Instance.new('Weld')
        w.Part0 = primary_part
        w.Part1 = Player.Character.Torso
        w.C1 = CFrame.Angles(math.rad(90),math.rad(-90),0)
        w.Parent = primary_part

        for index = 1, 15 do
            local part = RinkakuModel["Part" .. index] -- This will generate Part1 till Part15
            local weld = Instance.new("Weld")
            weld.Part0 = primary_part
            weld.Part1 = part
            weld.C1 = part.CFrame:toObjectSpace(primary_part.CFrame)
            weld.Parent = primary_part
        end

        RinkakuModel.Parent = Player.Character
    end
end)

You do not want to Anchor welds. If you do that, the Player won't be able to move.

The actual issue with nothing happening is because you have return weldon line 26: this exits the function. Additionally, the SetPrimaryPartCFrame and MakeJoints calls are redundant and unnecessary.

I suggest you read up on welds before you try and meddle with C1 and C0 more. It'll help. :)

Ad

Answer this question