So I’m making a killstreak glove(based on slap battles)and the “PlayerHit” StringValue doesn’t go into the “eChar” variable.
task.wait(1)
local tool = script.Parent
local hitChars = {}
local Power = script.Power
local sss = game:GetService("ServerScriptService")
local modules = sss:WaitForChild("Modules")
local attackmod = require(modules:WaitForChild("Attack"))
local plr = tool:FindFirstAncestorWhichIsA("Player")
local character
if plr == nil then
character = tool.Parent
else
character = plr.Character
end
local hum = character:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local attackAnim = animator:LoadAnimation(script:WaitForChild("Attack"))
local attackData = {
Damage = 0 + Power.Value,
StartUp = 0.2,
Knockback = Vector2.new(40 + Power.Value,20),
Stun = 2,
Linger = 0.4,
Sound = "Bonk"
}
local debounce = false
tool.Activated:Connect(function()
if debounce then
return
end
debounce = true
attackAnim:Play()
attackmod.Start(character, tool, attackData)
wait(1)
debounce = false
end)
tool.Hitbox.Touched:Connect(function(hit)
local plrChar = tool.Parent
local eChar = hit.Parent
if eChar ~= character and not debounce then
debounce = true
local playerHit = game.ServerStorage:FindFirstChild("PlayerHit")
if playerHit then
print(playerHit.Parent)
if eChar:FindFirstChild("PlayerHit") then
else
print(playerHit.Parent)
local clonedPlrHit = playerHit:Clone()
clonedPlrHit.Value = plrChar.Name
clonedPlrHit.Parent = eChar
if clonedPlrHit.Parent == workspace then
clonedPlrHit.Parent = game.ServerStorage
end
print(playerHit.Parent)
end
end
wait(1)
debounce = false
end
end)
script.Power.Changed:Connect(function()
Power.Value = Power.Value
end)
3 Likes
Instances stored inside of ServerStorage aren’t able to be retrieved by LocalScripts, so if your script is a LocalScript then PlayerHit will be nil
1 Like
1.This script is a normal one.
2.It just appears in workspace everytime i hit someone.
I think what happening is that the touch part is being triggered by a part that’s not inside of a player character, so I recommend checking to see if the hit.Parent has a Humanoid before running the rest of the code
1 Like
Now the “PlayerHit” StringValue just doesn’t appear at all.
1 Like
How does the code look like now?
task.wait(1)
local tool = script.Parent
local hitChars = {}
local Power = script.Power
local sss = game:GetService("ServerScriptService")
local modules = sss:WaitForChild("Modules")
local attackmod = require(modules:WaitForChild("Attack"))
local plr = tool:FindFirstAncestorWhichIsA("Player")
local character
if plr == nil then
character = tool.Parent
else
character = plr.Character
end
local hum = character:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local attackAnim = animator:LoadAnimation(script:WaitForChild("Attack"))
local attackData = {
Damage = 0 + Power.Value,
StartUp = 0.2,
Knockback = Vector2.new(40 + Power.Value,20),
Stun = 2,
Linger = 0.4,
Sound = "Bonk"
}
local debounce = false
tool.Activated:Connect(function()
if debounce then
return
end
debounce = true
attackAnim:Play()
attackmod.Start(character, tool, attackData)
wait(1)
debounce = false
end)
tool.Hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plrChar = tool.Parent
local eChar = hit.Parent
if eChar ~= character and not debounce then
debounce = true
local playerHit = game.ServerStorage:FindFirstChild("PlayerHit")
if playerHit then
print(playerHit.Parent)
if eChar:FindFirstChild("PlayerHit") then
else
print(playerHit.Parent)
local clonedPlrHit = playerHit:Clone()
clonedPlrHit.Value = plrChar.Name
clonedPlrHit.Parent = eChar
if clonedPlrHit.Parent == workspace then
clonedPlrHit.Parent = game.ServerStorage
end
print(playerHit.Parent)
end
end
wait(1)
debounce = false
end
end
end)
script.Power.Changed:Connect(function()
Power.Value = Power.Value
end)
Well I’m quite confused as to what might be causing the PlayerHit clone to always be parented to Workspace as there doesn’t seem to be anything that stands out as the cause, so I’ll try to rewrite the Touched function and will edit this reply when I’m done
local ServerStorage = game:GetService("ServerStorage")
local playerHit = ServerStorage.PlayerHit
tool.Hitbox.Touched:Connect(function(hit)
if debounce then return end
local model = hit:FindFirstAncestorOfClass("Model")
if model and model ~= character then
if model:FindFirstChild("PlayerHit") then return end
local humanoid = model:FindFirstChildWhichIsA("Humanoid")
if humanoid then
debounce = true
local playerHitClone = playerHit:Clone()
playerHitClone.Value = character.Name
playerHitClone.Parent = ServerStorage
task.wait(1)
debounce = false
end
end
end)
@ALTHumanYessir
Have you checked what exactly the hit
variable is whenever PlayerHit
appears in workspace? Print the hit variable and see what appears in the output.
In the output it prints “Workspace”
That doesn’t sound right. The touched event always returns a BasePart. Are you sure you’re printing the hit
variable and not hit.Parent?
Oh wait,my bad.
I printed the “eChar” variable.
It now prints “Baseplate” instead of “Workspace”.
What does the hitbox part look like? I don’t know how your glove looks, but you mentioned that it was based off of Slap Battles.

Ideally, the hitbox shouldn’t be hitting the Baseplate
consistently. Can you send an image of the tool and hitbox when you have it equipped?
1 Like
What about in game? Is the hitbox part welded to the tool’s handle
?
1 Like
Oh wait…
I’m actually so stupid.
It isn’t even welded to it…
Haha, that is the root of your problem then. Make sure it’s welded and then also check that eChar
(hit.Parent) has a humanoid like @JohhnyLegoKing previously mentioned.
1 Like
Basically uh,the error is still here.
I tried everything you guys mentioned,but it still have the same error.