I want to learn how to disable a function. So once the next match starts, the UI doesn’t change for the person who is no longer the Killer. It only changes for the current killer.
[Example]
if player == "Killer" then
Ui.MouseEnter:Connect(function()
Ui.Textlabel.Text = "Mouse Entered"
end)
Ui.MouseLeave:Connect(function()
Ui.Textlabel.Text = "Mouse Left"
end)
else
print(whatever)
end
If there’s a better way of doing this, knowing would also be beneficial.
You can make a local variable and when you need the function you set the variable to the function and when you need to stop it you use variable:Disconnect()
For example:
local Connection --the variable which will store the connection.
Connection = Ui.MouseEnter:Connect(function() --setting the variable to the connection. (you cannot directly set the variable, it has to be nil first)
Ui.Textlabel.Text = "Mouse Entered"
end)
Connection:Disconnect() --prevents the connection to be fired again.