Input is making my character turn invisible

Im trying to make a script where when a player is with a tool and when he stars an input a particle emitter connected to a part will attach to his arm, but when the input starts the character disappear, he just get deleted from the workspace

local player = game.Players.LocalPlayer
local character = player.Character
local tool = script.Parent
local skills = game.ReplicatedStorage.Skills.Wind

local uis = game:GetService("UserInputService")

local equip = false

tool.Equipped:Connect(function()
	equip = true
end)	
	
tool.Unequipped:Connect(function()
	equip = false
	local arm = character:FindFirstChild("RightArm")
	local charge = arm:FindFirstChild("Charge")
	if charge then 
		charge:Destroy()
	end
end)

uis.InputBegan:Connect(function(input, GPE)
	if input.KeyCode == Enum.KeyCode.E then
		if equip == true then
			print("yeah")
			local arm = character:FindFirstChild("RightArm")
			local charge = skills.Charge:Clone()	
			character.Parent = arm
			local weld = Instance.new("WeldConstraint")
			weld.Part0 = arm
			weld.Part1 = charge
			weld.Parent = charge
			charge.Parent = game.Workspace.Ignore
		else
			return
		end		
	end
end)

uis.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		local arm = character:FindFirstChild("RightArm")
		local charge = arm:FindFirstChild("Charge")
		charge:Destroy()
	end
end)
local player = game.Players.LocalPlayer
local character = player.Character
local tool = script.Parent
local skills = game.ReplicatedStorage.Skills.Wind

local uis = game:GetService("UserInputService")

local equip = false

tool.Equipped:Connect(function()
	equip = true
end)	
	
tool.Unequipped:Connect(function()
	equip = false
	local arm = character:FindFirstChild("RightArm")
	local charge = arm:FindFirstChild("Charge")
	if charge then 
		charge:Destroy()
	end
end)

uis.InputBegan:Connect(function(input, GPE)
	if input.KeyCode == Enum.KeyCode.E then
		if equip == true then
			print("yeah")
			local arm = character:FindFirstChild("RightArm")
			local charge = skills.Charge:Clone()	
			charge.Parent = arm
			local weld = Instance.new("WeldConstraint")
			weld.Part0 = arm
			weld.Part1 = charge
			weld.Parent = charge
			charge.Parent = game.Workspace.Ignore
		else
			return
		end		
	end
end)

uis.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		local arm = character:FindFirstChild("RightArm")
		local charge = arm:FindFirstChild("Charge")
		charge:Destroy()
	end
end)
1 Like

now the character dont turn invisible, but the part is not going getting the arm as parent and when the input end the game crash

Wait the entire game is crashing? Tell ne if that happens after this adjustment

local player = game.Players.LocalPlayer
local character = player.Character
local tool = script.Parent
local skills = game.ReplicatedStorage.Skills.Wind

local uis = game:GetService("UserInputService")

local equip = false

tool.Equipped:Connect(function()
	equip = true
end)	

tool.Unequipped:Connect(function()
	equip = false
	local arm = character:FindFirstChild("RightArm")
	local charge = arm:FindFirstChild("Charge")
	if charge then 
		charge:Destroy()
	end
end)

uis.InputBegan:Connect(function(input, GPE)
	if input.KeyCode == Enum.KeyCode.E then
		if equip == true then
			print("yeah")
			local arm = character:FindFirstChild("RightArm")
			local charge = skills.Charge:Clone()	
			charge.Parent = arm
			charge:PivotTo(arm:GetPivot())
			local weld = Instance.new("WeldConstraint")
			weld.Part0 = arm
			weld.Part1 = charge
			weld.Parent = charge
			--charge.Parent = game.Workspace.Ignore -- why are you moving it here?
		else
			return
		end		
	end
end)

uis.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		local arm = character:FindFirstChild("RightArm")
		if not arm then return end
		local charge = arm:FindFirstChild("Charge")
		charge:Destroy()
	end
end)
1 Like

thanks for the help man, but i find the error, the right name to the arm is “Right Arm” not "RightArm lol

and the part of two parents for the charge particle was an error of typing, sorry lol

1 Like

Okay, you’ve marked your own post which is unrelated to the original problem as the solution but keep in mind your problem was “Input is making my character turn invisible,” which I solved with this line:

replacing your former line

This is the real solution to your topic.

Also this code that I added makes the charge be positioned correctly:

charge:PivotTo(arm:GetPivot())
1 Like

truly sorry, i marked and unmarked later, there wer no issue at the code, i just typed the wrong name
now i marked your answer as the solution, sorry for wasting your time

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.