Tool equips sucessfully but don’t know why but my rope gun is not working
local script
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Tool = script.Parent
local HoldingTool = false
Tool.Equipped:Connect(function()
HoldingTool = true
end)
Tool.Unequipped:Connect(function()
HoldingTool = false
end)
mouse.Button1Down:Connect(function()
--[[if HoldingTool == true then
local ropeRemote = ReplicatedStorage:WaitForChild("RopeRemote")
ropeRemote:FireServer(mouse.p)
end]]--
local ropeRemote = ReplicatedStorage:WaitForChild("RopeRemote")
ropeRemote:FireServer(mouse.p)
end)
server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RopeRemote = nil
if ReplicatedStorage:FindFirstChild("RopeRemote") then
RopeRemote = ReplicatedStorage.RopeRemote
else
RopeRemote = Instance.new("RemoteEvent", ReplicatedStorage)
RopeRemote.Name = "RopeRemote"
end
local RopeLine = nil
RopeRemote.OnServerEvent:Connect(function(user, Point)
pcall(function()
if Point ~= nil then
if RopeLine == nil then
local RopeAtc1 = Instance.new("Attachment")
local RopeAtc2 = Instance.new("Attachment")
RopeAtc1.Position = script.Parent.Handle.Position
local RopePart = Instance.new("Part")
RopePart.Position = Point
RopePart.Size = Vector3.new(0.05, 0.05, 0.05)
RopePart.CanCollide = false
RopePart.Anchored = true
RopePart.CastShadow = false
RopePart.Transparency = 1
RopeAtc2.Position = RopePart.Position
RopeAtc1.Parent = script.Parent.Handle
RopeAtc2.Parent = RopePart
RopeLine = Instance.new("RopeConstraint", script.Parent.Handle)
RopeLine.Attachment0 = RopeAtc1
RopeLine.Attachment1 = RopeAtc2
else
RopeLine.Attachment1.Parent:Destroy()
RopeLine.Attachment0:Destroy()
RopeLine:Destroy()
end
end
end)
end)