Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i spawn a part from ServerStorage?

I was creating a script that spawns a specific part with code from the ServerStorage when i press E. However, i can't figure out what to do next. Here is the entire code:

local pillar = game.ServerStorage.pillarthing
pillarclone = pillar:Clone()
pillarclone.Parent = workspace
local player = game.Players.LocalPlayer
local character = player.Character
pillarclone.Position = character

function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.E then
		
	end
end
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

1 answer

✓ Accepted answer
local pillar = game.ServerStorage.pillarthing
local player = game.Players.LocalPlayer
local character = player.Character
 
function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.E then
pillarclone = pillar:Clone()
pillarclone.Parent = workspace
pillarclone.CFrame = character:FindFirstChild("HumanoidRootPart").CFrame
    end
end
 
game:GetService("UserInputService").InputBegan:Connect(onKeyPress)

That goes inside the StarterGui and local script, use :Connect() instead of :connect() because :connect() is deprecated.

If this worked please mark this question as answered, or accept answer.

5 comments

0

Still don't understand why the hell they decided to deprecate the lower-case Connect :/

0

It is not a really big deal just for an uppercase C you know :P.

0

It worked perfectly. Thanks.

0

no problem :)

0

They deprecated lower-case methods because ROBLOX wanted to shift their naming conventions to upper-camel-case.

This discussion is preserved as it was. New answers, comments, and votes are closed.