Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Touch function not detecting players that are standing still?

** So my problem is the touch function… I have this hitbox that is supposed to damage the player then delete itself. But if the Player isn't moving it does not do any damage. I've tried gettouchedparts but that was too complicated for me so I didn't know how to put it in my script. Is there any alternative way to fix this ?**

hitbox.Touched:Connect(function(hit)
if hit.Parent.Name ~= Player.Name then 
local gethum = hit.Parent:FindFirstChild("Humanoid")
if gethum then
hitbox.CanCollide = false
hitbox:Destroy()
gethum:TakeDamage(5)

1 answer

When a player is not moving, the touched function doesn't work because none of the player's body parts are updating the hitbox.

local hitbox = workspace.hitbox -- or whatever your hitbox is called

hitbox.Touched:Connect(function(hit)
local gethum = hit.Parent:FindFirstChild("Humanoid")
local Player = gethum.Parent

if hit.Parent.Name ~= Player.Name then 
if gethum then
hitbox.CanCollide = false
hitbox:Destroy()
gethum:TakeDamage(5)
end
end
end)

3 comments

0

Please don't write everything on the same row, it's much easier to read if you tab in

0

Now im having an error that Ive tried to fix called " is not a valid member of Workspace "Workspace"" How should I fix this?

0

With the local hitbox make sure to locate that part the player will touch to activate the script. e.g. (workspace.replace with part position)

This discussion is preserved as it was. New answers, comments, and votes are closed.