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

How do i spawn a part from ServerStorage?

Asked by 5 years ago

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

Log in to vote
1
Answered by
valchip 789 Moderation Voter
5 years ago
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.

0
Still don't understand why the hell they decided to deprecate the lower-case Connect :/ superender11 -17 — 5y
0
It is not a really big deal just for an uppercase C you know :P. valchip 789 — 5y
0
It worked perfectly. Thanks. JamarMario 13 — 5y
0
no problem :) valchip 789 — 5y
0
They deprecated lower-case methods because ROBLOX wanted to shift their naming conventions to upper-camel-case. ScriptGuider 5640 — 5y
Ad

Answer this question