in my code system, there is a value at the end of my code:
task.delay(2, function()
if hitSomething == false then
print("Client Missed")
game:GetService("ReplicatedStorage").PlayerStorage[plr.Name].Value = false
end
end)
end
The value wont change at all! Heres my main code:
local module = {}
local animations = {
start = game:GetService("ReplicatedStorage").AccessStorage.Animations.Moves.Ravage.RavageStart,
success = game:GetService("ReplicatedStorage").AccessStorage.Animations.Moves.Ravage.Ravage,
enemyAnimation = game:GetService("ReplicatedStorage").AccessStorage.Animations.Moves.Ravage.RavageEnemy
}
function module.Start(plr)
local character = plr
if not character then return end
local hrp = character:FindFirstChild("HumanoidRootPart")
if not hrp then return end
game:GetService("ReplicatedStorage").PlayerStorage[plr.Name].Value = true
local hitbox = Instance.new("Part")
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.Parent = workspace.HitboxService
hitbox.Size = Vector3.new(5, 6, 5)
hitbox.CFrame = hrp.CFrame * CFrame.new(0, 0, -3)
hitbox.BrickColor = BrickColor.new("Black")
hitbox.Transparency = 0.5
local highlight = Instance.new("Highlight")
highlight.Parent = hitbox
highlight.Adornee = hitbox
highlight.FillTransparency = 1
highlight.OutlineColor = Color3.new(1, 0, 0)
highlight.OutlineTransparency = 0
local hitDebounce = {}
local hitSomething = false
hitbox.Touched:Connect(function(hit)
local char = hit.Parent
local humanoid = char and char:FindFirstChild("Humanoid")
if not humanoid then return end
if hitDebounce[humanoid] then return end
hitDebounce[humanoid] = true
hitSomething = true
local animator = humanoid:FindFirstChildOfClass("Animator")
if animator then
local track = animator:LoadAnimation(animations.start)
track:Play()
end
end)
game:GetService("Debris"):AddItem(hitbox, 2)
task.delay(2, function()
if hitSomething == false then
print("Client Missed")
local rp = game:GetService("ReplicatedStorage")
local value = rp.PlayerStorage:FindFirstChild(plr.Name)
if value then
value.Value = false
end
end
end)
end
return module
First, confirm that the message âClient Missedâ is printed in output. When the value should be changed, this message should pop up as well.
Next, verify that the object retrieved from local value = rp.PlayerStorage:FindFirstChild(plr.Name) is indeed the BoolValue instance that you want to change. This can be done by printing out the value objectâs full name after retrieving using print(value:GetFullName()).
Then, check the running environment. If the object is correct, then the value.Value should be set to false in the same environment as the script (Client if client-sided script, Server if server-sided script). Double check that you are running the script at the environment that you desired.
Other potential ways of identifying the issue is to add print statements to see if each step is ran correctly.
The getting/setting of the value object (presumably a BoolValue) looks fine, but there are other possible problems I see right off:
Are you passing a Player instance to this function or a character Model reference? If itâs a Player, you should change the line to local character = plr.Character. If itâs a character Model, then for your own sanity and those trying to help, donât name the parameter âplrâ.
Also, you appear to initialize hitSomething to false, and then set it to true, but I see no code that ever sets it back to false, which should presumably be happening after some event or amount of time.
Likewise for hitDebounce[humanoid], I would expect to see hitDebounce[humanoid] = nil somewhere in the code to clear this, like after the animation plays. That is, unless you intend for only being able to record a collision with another character once each, in which case this is fine. I just wanted to make sure you intend for this map to fill up and nothing be removed from it.