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

How to weld a shockwave when a user presses a button?

Sorry I am asking this again I am just super confused I keep getting "HumanoidRootPart is not a valid member of model"

local uis = game:GetService('UserInputService')
local player = game.Players.LocalPlayer
local shockwave = game.Workspace.Shockwave
local connect = player.Character.HumanoidRootPart

shockwave.Transparency = 1

local weld = Instance.new('Weld')
weld.Part0 = connect
weld.Part1 = shockwave
weld.Parent = connect

uis.InputBegan:Connect(function(input, proccessedEvent)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.C then
			shockwave.Transparency = 0
		end
		shockwave.Transparency = 1
	end
end)

2 comments

0

Try adding player.Character:WaitForChild("HumanoidRootPart") on line 4.

0

nope

1 answer

I changed the code a bit and it seemed to work

local inputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local shockwave = workspace:WaitForChild("Shockwave")
local connect = workspace:FindFirstChild(player.Name)

shockwave.Transparency = 1

local weld = Instance.new("Weld")
weld.Part0 = connect
weld.Part1 = shockwave
weld.Parent = connect

inputService.InputBegan:Connect(function(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.C then
			shockwave.Transparency = 0
		end
	end
end)

For some reason it doesn't create the weld, but it doesn't give any errors so I don't know what's happening there.

If you want to make the shockwave disappear when the key is released you can use the InputEnded event.

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