i need help fixing my current script as it currently doesnt work as intended
What do you want to achieve?
I wanna be able to phase through certain parts on my map when i have a certain tool equipped/held
What is the issue?
with the scripts ive made either A: i can walk through the target parts with and without the tool equipped
or B: i cant go through the target parts at all
ive tried turning collisions off and on via scripts on the tools and tried searching on the dev forum for help but nobody seems to had have a problem like mine
script (script is inside the tool itself)
Players = game:GetService("Players")
Tool = script.Parent
Handle = Tool:WaitForChild("Handle")
if Tool.Equipped == true then
workspace.Door.CanCollide = false
workspace.Door.Transparency = 0.5
if Tool.Equipped == false then
workspace.Door.CanCollide = true
workspace.Door.Transparency = 0
end
end
First of all, why are both your ends at the bottom of the script?
Second of all, why are all your variables global?
Tools have an event called .Equipped which fire when the player equips the tool and another event called .Unequipped which fires when the player unequips the tool.
Try seeing if this works:
local Players = game:GetService("Players")
local tool: Tool = script.Parent
local handle = tool:WaitForChild("Handle")
tool.Equipped:Connect(function()
workspace.Door.CanCollide = false
workspace.Door.Transparency = 0.5
end)
tool.Unequipped:Connect(function()
workspace.Door.CanCollide = true
workspace.Door.Transparency = 0
end)