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

How can I clone objects into an R15 body part of all players?

Asked by 4 years ago
Edited 4 years ago

Hello there, I am sort of new here, and I hope you can understand my problem.

With my script, I would like to clone a SurfaceGUI into the UpperTorso part of every player character inside the game. After running the script, it does not throw any errors, however, the SurfaceGUI fails to show up on the UpperTorso, and the object I want to clone does not show up in the player's UpperTorso in the Explorer, either. I have also tried cloning other types of objects into the UpperTorso too, and they do not seem to get cloned, either. I have also read about how SurfaceGUIs need an Adornee, it would be great if someone explained that, too.

My script is:


local Players = game:GetService("Players") Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local uppert = character.UpperTorso if uppert then local that = script.BackNumber:Clone() that.Parent = uppert end end) end)

The BackNumber SurfaceGUI object is in the Script itself, and it has a TextLabel inside it.

Thanks in advance for the help.

0
that.Adornee = uppert? Also, :connect is deprecated in favour of :Connect programmerHere 371 — 4y
0
I can't test it out right now, but I'm pretty sure I also have to set the Parent too somehow, not just the Adornee, but I don't know how, it doesn't work. SuperBoi666 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

In terms of the SurfacGui you'll need to make sure you set the adornee and face to where you want. Judging from your script you want it on the back.

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local uppert = character.UpperTorso
        if uppert then
            local that = script.BackNumber:Clone()
            that.Adornee = uppert --Sets the gui to show up on the upper torso
            that.Face = "Back" --Sets the gui to show up on the back of the upper torso
            that.Parent = uppert
        end
    end)
end)

Now in terms of parts in case you're unsure, you need to make sure that you're setting the CFrame of the cloned part to that of the part you want it to be attached to and then use a weld constraint once it's positioned how you want. All you'll really have to do for the weld is set it's Part0 and Part1 to the 2 parts

0
Hi, thanks for the answer, but it didn't work. Again, no errors are thrown and it's not doing what it's supposed to do. I entirely don't know what causes the problem. SuperBoi666 0 — 4y
0
Then it's probably something outside of the script that's causing it to happen. The script I provided works fine in testing so you may want to make sure that your script is located in the proper place like ServerScriptService or that it's not disabled because, from what it sounds like, the script just isnt running at all. Try putting prints after the player and character added events and see. XxTrueDemonxX 362 — 4y
0
My script isn't disabled, and no matter where I place it, it doesn't work. I've tried putting prints after each event to see what fails to work, and they didn't help me find out. I would like to ask you a favour if you still want to help: please send me an uncopylocked place or a place file that contains your script, and is working, because no matter what I do, it doesn't want to work for me. SuperBoi666 0 — 4y
0
I have no clue how to actually send worlds, never been something I've had to do before, but it's a very simple thing to setup. Just put the above code in a script in a blank world in the ServerScriptService, then copy the backnumber gui into it as a child. Assuming your GUI IS enabled and everything that needs to be visible is visible, it'll show up. XxTrueDemonxX 362 — 4y
Ad

Answer this question