I have a lighter tool which is supposed to work after being dropped but doesn’t for whatever reason. I’ve tried fixing this various times but have been unsuccessful.
Lighter LocalScript:
--<< NotFrindow >>--
local player = game:GetService("Players").LocalPlayer
player.CharacterAdded:Wait()
local character, mouse = player.Character, player:GetMouse()
mouse.TargetFilter = workspace.Map.MouseIgnore
local tool = script.Parent
local uis = game:GetService("UserInputService")
local lighterKeybind = Enum.KeyCode.F
tool.Equipped:Connect(function()
uis.InputBegan:Connect(function(inputObject, gpe)
if gpe == false then
if inputObject.KeyCode == lighterKeybind then
print(player, character, mouse, tool, uis, lighterKeybind)
if tool.isOn.Value == true then
if mouse.Target.Parent:FindFirstChild("Class") and
mouse.Target.Parent.Class.Value == "Candle" then -- Light candle
local ray = Ray.new(mouse.Hit.Position, character.PrimaryPart.Position - mouse.Hit.Position)
local part, position = game.Workspace:FindPartOnRay(ray)
local distance = (mouse.Hit.Position - position).Magnitude
if distance <= 5.1 then
print("Within lightable range" .. " (" .. distance .. " studs)")
game.ReplicatedStorage.LightCandle:FireServer(mouse.Target.Parent)
else
warn("Not within lightable range" .. " (" .. distance .. " studs)")
end
end
end
end
end
end)
end)
When the drop key (G) is pressed a RemoteEvent is fired, here is the script (in SSS) for the RemoteEvent:
--<< NotFrindow >>--
local remote = game:GetService("ReplicatedStorage").DropTool
local tools = game:GetService("ServerStorage").Tools
remote.OnServerEvent:Connect(function(player, tool)
tool.Parent = workspace.Map.Temp
-- tool:WaitForChild("Equipped").Value = false
player.toolsEquipped.Value = player.toolsEquipped.Value - 1
local collisionAddedParts = {}
for i, part in pairs(tool:GetChildren()) do
if part:IsA("BasePart") then
if part.CanCollide == false then
part.CanCollide = true
table.insert(collisionAddedParts, part)
end
end
end
tool:GetPropertyChangedSignal("Parent") do
for i, part in pairs(collisionAddedParts) do
part.CanCollide = false
end
end
end)