Can someone help me disable this script upon death. In the script the shiftlock disables upon unequipping the tool. I want it also to do the same thing if the character dies.
local tool = script.Parent
local uis = game:GetService("UserInputService")
local equipped = false
local cam = workspace.CurrentCamera
tool.Equipped:Connect(function()
equipped = true
game.Players.LocalPlayer.CameraMaxZoomDistance = 15
if equipped then
_G.ForceShiftLock = true
uis.MouseIconEnabled = false
end
end)
tool.Unequipped:Connect(function()
equipped = false
game.Players.LocalPlayer.CameraMaxZoomDistance = 15
_G.ForceShiftLock = false
uis.MouseIconEnabled = true
end)
I tried this but it doesnt like line 31 when i attempt to call the dead function.
local tool = script.Parent
local uis = game:GetService("UserInputService")
local equipped = false
local cam = workspace.CurrentCamera
tool.Equipped:Connect(function()
equipped = true
game.Players.LocalPlayer.CameraMaxZoomDistance = 15
if equipped then
_G.ForceShiftLock = true
uis.MouseIconEnabled = false
end
end)
tool.Unequipped:Connect(function()
equipped = false
game.Players.LocalPlayer.CameraMaxZoomDistance = 15
_G.ForceShiftLock = false
uis.MouseIconEnabled = true
end)
function dead()
game.Players.LocalPlayer.CameraMaxZoomDistance = 15
_G.ForceShiftLock = false
uis.MouseIconEnabled = true
end
local Character = tool.Parent
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
Humanoid.Died:Connect(dead)
When a player dies, the tool is still being equipped somehow, to solve your problem, try destroying the tool instead when a player dies by putting these in a server script in Server Script Service:
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
for i, v in ipairs(character:GetChildren()) do
if v:IsA("Tool") then
v:Destroy()
end
end
_G.ForceShiftLock = false
end)
end)
end)