At the current moment I want to do a double check like I was recommended for my previous post. Although I need a Medium where I can used a Touched Event for the client to figure out what it is hitting at the moment, then decide on the server if that is what is trying to be hit and do the damage.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local Mouse = Player:GetMouse()
--\\ Debouncing Variables //--
local Enabled = true
local Count = 1
--\\ Services //--
local UIS = game:GetService("UserInputService")
--\\ Combat Activation //--
local S = script
local RE = S:WaitForChild("Combat")
----------------------------------------
--\\ Functions //--
UIS.InputBegan:Connect(function(Input, Processed)
if Processed then
return
end
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
if Enabled then
local CFrames = HRP.CFrame * CFrame.new(0, 0, -2)
script.Parent.Touched:Connect(function(hit, blacklist) --Issue comes here wher eI want to get the script to work.
blacklist = {game.Part, game.Part:FindFirstChild("ParticleEmitter"), game.ReplicatedStorage.Hitbox, game.ReplicatedStorage.Cloudy, game.ReplicatedStorage["Charge up Partcile"], game.ReplicatedStorage.Events}
--Blacklisting things I don't want to be counted as a damagable item/basepart. ^^^
if Character.Hit == blacklist then return end
if Count == 1 and Character.Hit ~= blacklist then
Count = 2
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://7246225588"
local AnimP = Character.Humanoid:LoadAnimation(Anim)
AnimP:AdjustSpeed(3)
AnimP:Play()
elseif Count == 2 then
Count = 3
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://7246227343"
local AnimP = Character.Humanoid:LoadAnimation(Anim)
AnimP:AdjustSpeed(3)
AnimP:Play()
elseif Count == 3 then
Count = 4
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://7246232053"
local AnimP = Character.Humanoid:LoadAnimation(Anim)
AnimP:AdjustSpeed(3)
AnimP:Play()
elseif Count == 4 then
Count = 1
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://7246223838"
local AnimP = Character.Humanoid:LoadAnimation(Anim)
AnimP:AdjustSpeed(3)
AnimP:Play()
end
RE:FireServer("Combat", CFrames, hit)
end)
end
end
end)
The error happens because script.Parent is the backpack and the backpack does not support a Touched connection.
if Character.Hit == blacklist then return end You can’t compare hit with a table like that, you will have to iterate through the table and compare each object with hit individually.
Your Enabled debounce isn’t being used correctly, as you never set it to false.
You are attempting to create a connection inside a connection, which isn’t good as that could in theory end up creating multiple connections if not handled properly.
You dont need to store the script in a variable like you did with local S = script
Also instead of creating the Touched connection client sided and validating it on the server, you could simply just create it server sided and then you will always know it’s legit.
So, what could instead since the Backpack will not work. The general way someone was showing me was through a Touched Event, but I won’t be able to do that if I can’t even run the Touched Event
So I’d have to run an i,v for pairs for everything in the table? Per Animation? To check for what was hit then verify and deny anything in the blacklist?
Oh, I was never good with debounces. I’ll look more into them but my understanding of them is very low.
Is there an alternative/better way or method of doing this that I can learn? I have done this method many times, but it often worked out with little to no issues.
I just like it better. Personal preference I would say.
The server is already handling creating the hitbox, but the issue with that was related to a latency issue so that’s why I’m trying to do the touched event method and get it verified again in the server. It looks like this at the moment, and I want to fix it.
Touched connections can only be used on physical objects like parts, unions, and meshes. I do not know what you are wanting to be touched to fire the connection. But because you put it inside an InputBegan connection, the touch connection will never exist unless the input was made. And every time you make a new input, it creates another connection, and another, and another… see my point?
Yea you would have to iterate through the blacklist table and and check if whatever hit is, matches what is in the table. Also note: Character.Hit does not exist, as Hit is not a property of the Character. If you want to check if a limb was touched, you need to use .Touched on the limb. Also your blacklist contains objects that can not be touched, since only BaseParts can be touched.
Debounces are fairly simple. They are mainly used to prevent code from being ran after a set amount of time. You simply check if its true or false, then set it to the opposite, wait some time, then set it back to how it was. That easy.
Refer to what I mentioned in #1
It’s using up an unnecessary variable space in the script and in the memory. Yes there is a limit to how many variables you can have in a script. Also as for performance, probably wouldn’t help either.
So, at the current moment I’d have to find a different method? I just want the latency to get much easier to deal with. So, I don’t deal with lasting hitboxes/inaccurate hitboxes on the server.