I want to make a damage part check for IFRAME attribute on player before calculate the damage, for example, while IFRAME == True, don’t do any damage if false then the opposite
the problem is even if I reference the variable to the Humanoid (Where all attribute is) the script can’t find it
Damage Brick Script (the part I want to check if player has IFRAME
local crosshair = script.Parent.Parent:FindFirstChild("MarkerGUI"):FindFirstChildWhichIsA("ImageLabel")
local bang = script.Parent.Parent:FindFirstChild("MarkerGUI"):FindFirstChildWhichIsA("Sound")
local reload = script.Parent.Parent:FindFirstChild("MarkerGUI"):FindFirstChild("reload")
local targetColor = Color3.new(1, 0, 0)
local targetSize = UDim2.new(1,150,1,150)
local TargetTransparency = 0
local Tween = game:GetService("TweenService")
local clicky = script.Parent
local Info = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
local rotateInfo = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
local Shrink = Tween:Create(crosshair.Parent, Info, {Size = targetSize})
local imageAppear = Tween:Create(crosshair, Info, {ImageTransparency = TargetTransparency})
local rotate = Tween:Create(crosshair, rotateInfo, {Rotation = 0})
local Color = Tween:Create(crosshair, Info, {ImageColor3 = targetColor})
local Damage = 100
local function perciseShot(player) -- Function to handle the precise shot
if player then
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then -- all of this rn just play Tween and deal damage without checking for IFRAME
crosshair.Parent.Adornee = character:FindFirstChild("HumanoidRootPart")
wait(2)
reload:Play()
Shrink:Play()
imageAppear:Play()
rotate:Play()
Color:Play()
Color.Completed:Wait()
humanoid:TakeDamage(Damage)
bang:Play()
crosshair.Parent.Adornee = nil
crosshair.ImageTransparency = 1
crosshair.Parent.Size = UDim2.new(1,1000,1,1000)
crosshair.ImageColor3 = Color3.new(0,0,0)
crosshair.Rotation = 180
end
end
end
clicky.MouseClick:Connect(perciseShot) -- Connect the function to the MouseClick event
Player Local Script
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootpart = character:WaitForChild("HumanoidRootPart")
local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local Input = game:GetService("UserInputService")
local DodgeAnim = Instance.new("Animation")
DodgeAnim.AnimationId = "rbxassetid://88253009476893"
local dodgeTrack = script.Parent.Humanoid:LoadAnimation(DodgeAnim)
Humanoid:SetAttribute("IFRAME", false)
local DodgeDebounce = false
Input.InputEnded:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.E then
if DodgeDebounce == true then
return
else
DodgeDebounce = true
dodgeTrack:Play()
Humanoid:SetAttribute("IFRAME", true)
dodgeTrack.Stopped:Wait(.5)
DodgeDebounce = false
end
end
end)
Humanoid:GetAttributeChangedSignal("IFRAME"):Connect(function()
if Humanoid:GetAttribute("IFRAME") == true then
print("Has IFrame")
wait(.3)
Humanoid:SetAttribute("IFRAME", false)
elseif Humanoid:GetAttribute("IFRAME") == false then
print("No IFrame")
end
end)