Flashlight equip/unequip error

  1. What do you want to achieve?
    im not good at scripting and i found this flashlight script/model on youtube and i want to when i unequip flashlight, firstperson model destroy

  2. What is the issue? my issue is when i unequip flashlight the firstperson model wont disapear, and when i equip the flashlight script making folders in workspace
    Képernyőfelvétel (78)
    robloxapp-20240716-2303055.wmv (1.5 MB)

scrip:

local equip_Fpart = game.ReplicatedStorage.flashlight_remote.flashlight_equip
local destroy_Fpart = game.ReplicatedStorage.flashlight_remote.flashlight_destory
local Fpart = game.ReplicatedStorage.Fpart

equip_Fpart.OnServerEvent:Connect(function(plr)
	local char = plr.Character
	local humanoid = char:FindFirstChild("Humanoid")
	
	local plr_folder = Instance.new("Folder")
	plr_folder.Parent = workspace
	plr_folder.Name = "w"..plr.Name
	
	local cloned = Fpart:Clone()
	cloned.Parent = plr_folder
	cloned.Name = plr.Name
	
	local weld = Instance.new("WeldConstraint")
	weld.Parent = plr_folder
	
	if humanoid.RigType == Enum.HumanoidRigType.R6 then
		print("rig type is r6")
		cloned.CFrame = char:FindFirstChild("Right Arm").CFrame * CFrame.new(0,-1,0)
		--cloned.Orientation = Vector3.new(0,0,0)
		weld.Part0 = cloned
		weld.Part1 = char:FindFirstChild("Right Arm")
	elseif  humanoid.RigType == Enum.HumanoidRigType.R15 then
		cloned.CFrame = char:FindFirstChild("RightHand").CFrame * CFrame.new(0,0,0)
		--cloned.Orientation = Vector3.new(0,0,0)
		weld.Part0 = cloned
		weld.Part1 = char:FindFirstChild("RightHand")
	end
	
	destroy_Fpart.OnServerEvent:Connect(function(plr)
		local g1 = plr_folder:FindFirstChild(plr.Name)
		local g2 = workspace:FindFirstChild("w"..plr.Name)
	end)
end)

and sorry if I wrote something wrong, im not good at english

1 Like

I think you need to update the orientation as it’s the same for the equipped one. So when its unequipped change the orientation of the tool to be different from the equipped one.

As I have seen, you are trying to remove the first person model that is made when you equip flashlight.

At the end of your script add

	destroy_Fpart.OnServerEvent:Connect(function(plr)
		local g1 = plr_folder:FindFirstChild(plr.Name)
		local g2 = workspace:FindFirstChild("w"..plr.Name)
        g2:Destroy()
	end)
end)

basically add g2:Destroy()
Let me know if I am wrong.
**Yeah :Destroy() not Destory, mb.

still wrong

(jsajsadjasjssajsajsaj)

1 Like

I think he meant :Destroy()

Not :Destory()

1 Like

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