So i spawn 2 parts one on the mouse and the othe one inside the player, its on hold so after i let go of the Key "E" the parts should delete, Help?

Any Tip would help me a lot :)))

Heres Local

wait(1)
local Player = game:GetService("Players").LocalPlayer

local rp = game:GetService("ReplicatedStorage")
local Hook = rp:WaitForChild("Events"):WaitForChild("Hook")

local Mouse = Player:GetMouse()


local UIS = game:GetService("UserInputService")

local debounce = false
local Active = false
local cooldown = 1



UIS.InputBegan:Connect(function(input,IsTyping)
	if IsTyping then
		return

elseif input.KeyCode == Enum.KeyCode.E then
	if debounce == false and Active == false then
		debounce = true
		local Character = Player.Character 
		local Humanoid = Character:FindFirstChild("Humanoid")
		local Position = Mouse.Hit.p


		Hook:FireServer(Active,Position)



		end
	end
end)

UIS.InputEnded:Connect(function(input,IsTyping)
	if IsTyping then
		return
	elseif input.KeyCode == Enum.KeyCode.E then
	if debounce == true and Active == false then
		Active = true
		local Character = Player.Character 
		local Humanoid = Character:FindFirstChild("Humanoid")
		local Position = Mouse.Hit.p

		Hook:FireServer(Active,Position)

		end	
	end
end)

And Heres Server Script

wait(1)
local Hook = game.ReplicatedStorage:WaitForChild("Events"):WaitForChild("Hook")
Hook.OnServerEvent:Connect(function(Player,Active,Position)
	local Character = Player.Character
	local Humanoid = Character.Humanoid
	local Start = game.ReplicatedStorage.Start:Clone()
	local End = game.ReplicatedStorage.End:Clone()
	if Active == false then	
		Start.Parent = game.Workspace
		End.Parent = game.Workspace
		End.Position = Position
	
	
		Start.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,0,0)
		Start.Orientation = Character.HumanoidRootPart.Orientation
		Start.Parent = workspace


		local Sweld = Instance.new("ManualWeld")
		Sweld.Name = "Rope Weld"
		Sweld.Part0 = Character:WaitForChild("HumanoidRootPart")
		Sweld.Part1 = Start
		Sweld.C0 = Character:WaitForChild("HumanoidRootPart").CFrame:inverse() * 	 
Start.CFrame
		Sweld.Parent = Sweld.Part0
	
	
	
	elseif Active == true then

		Start:Destroy()
		End:Destroy()		
	end

	Hook:FireClient(Player)
end)

2 comments

0

You never set changed the "Active" Boolean in your LocalScript.....

0

that doesnt matters even if i change it its still doesnt delets the spawned parts