What do you want to achieve?
I want to detect when a value is removed from the player.
Local Script:
local player = game.Players.LocalPlayer
local event = game.ReplicatedStorage.Sacrifice
local UIS = game:GetService("UserInputService")
local cd = false
local mouse = player:GetMouse()
local effect = game.Lighting.SacrificeEffect
mouse.KeyDown:Connect(function(key)
key = key:lower()
if key == 'h' and cd == false and not player.Character:FindFirstChild("Sacrificed") then
cd = true
event:FireServer()
wait(2.2)
effect.Enabled = true
wait(.1)
effect.Brightness = 0.2
wait(.1)
effect.Brightness = 0
wait(.1)
effect.Enabled = false
effect.Brightness = 0.2
cd = false
player.Character.Changed:Connect(function()
if not player.Character:FindFirstChild("Sacrificed") then
effect.Enabled = true
wait(.1)
effect.Brightness = 0.2
wait(.1)
effect.Brightness = 0
wait(.1)
effect.Enabled = false
effect.Brightness = 0.2
Server Script
local event = game.ReplicatedStorage.Sacrifice
local anim = script.Animation
event.OnServerEvent:Connect(function(player)
local char = player.Character
local hum = player.Character:WaitForChild("Humanoid")
local energy = hum:WaitForChild("sacEnergy")
local maxenergy = hum:WaitForChild("MaxSac")
local loadanim = hum:LoadAnimation(anim)
if not player.Character:FindFirstChild("Sacrificed") then
loadanim:Play()
wait(1)
char.LowerTorso.Dagger.Transparency = 1
char.RightHand.Dagger.Transparency = 0
wait(1)
hum:TakeDamage(10)
local val = Instance.new("BoolValue")
val.Name = "Sacrificed"
val.Parent = char
if energy.Value < maxenergy.Value then
energy.Value += 35
wait(3)
char.LowerTorso.Dagger.Transparency = 0
char.RightHand.Dagger.Transparency = 1
wait(15)
val:Destroy()
loadanim:Stop()
end
end
end)
I’m not getting any errors in output. Thank you for any help.