#Why does the hitbox not care about this boolvalue?
1 messages · Page 1 of 1 (latest)
im really confused since it was working early, probably a bug with either wifi or the module
send code in a codeblock
showing it in a video is very inefficient
oh yeah that makes sense
** You are now Level 3! **
ill get it ready
local attack = {}
attack.hitboxes = {}
function attack.hitboxmake(cooldown, tool, alreadyhit, size)
local hitbox = Instance.new("Part")
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.Size = size
hitbox.Color = Color3.new(1, 0.168627, 0.168627)
hitbox.Material = Enum.Material.ForceField
hitbox.Transparency = 0.3
hitbox.Parent = game.Workspace
hitbox.CFrame = tool.Parent.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5.5)
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= tool.Parent.Name and alreadyhit == false then
print("Hit")
print(hit.Parent.Name)
hit.Parent.Humanoid:TakeDamage(25)
alreadyhit = true
task.wait(cooldown)
end
end)
game.Debris:AddItem(hitbox, 0.5)
end
return attack
local m1event = game.ReplicatedStorage.Events.Killer["2011X"].m1
local stats = {
tool = script.Parent,
cooldown = 2,
alreadyhit = false,
size = Vector3.new(5, 6, 5),
duringattack = false,
keybind = Enum.UserInputType.MouseButton1,
}
local attack = require(game.ServerStorage.Modules.ModuleScript)
m1event.OnServerEvent:Connect(function()
print("Event received")
stats.tool:Activate()
end)
stats.tool.Activated:Connect(function()
if stats.duringattack == false then
print("Used Punch")
stats.duringattack = true
task.delay(stats.cooldown, function()
stats.duringattack = false
end)
local player = game.Players:GetPlayerFromCharacter(stats.tool.Parent)
local humanoid = player.Character:WaitForChild("Humanoid")
local animator = humanoid.Animator
local hitAnim = Instance.new("Animation")
hitAnim.AnimationId = "rbxassetid://125113366268147"
local hitTrack = animator:LoadAnimation(hitAnim)
if hitTrack then
hitTrack:Play()
hitTrack.Looped = false
end
for i = 1, 5 do
local hitbox = attack.hitboxmake(stats.cooldown, stats.tool, stats.alreadyhit, stats.size)
table.insert(attack.hitboxes, hitbox)
task.wait(0.05)
end
end
end)
print(stats.alreadyhit)```
youre passing stats.alreadyhit by value as a bool to the module function and not by reference
the module is getting a copy of the bool and when it changes that copy it doesnt affect the original
I assumed that was the problem, however im not sure how i could fix it?
would i keep the value outside the module?
how would i make it return the original instead?
i figured it out