So I made a “Touched” and “TouchEnded” to detect a part that is currently touching a zone.
local safe = game.Workspace.safezone.safezoneRoot
local takedamage = true
local Lobby = game.Workspace.Lobby
safe.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) and takedamage == true then
takedamage = false
print(takedamage)
end
end)
Lobby.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) and takedamage == true then
takedamage = false
print(takedamage)
end
end)
Lobby.TouchEnded:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) and takedamage == false then
takedamage = true
print(takedamage)
end
end)
safe.TouchEnded:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) and takedamage == false then
takedamage = true
print(takedamage)
end
end)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
while true do
while char and takedamage == true do
char.Humanoid:TakeDamage(math.random(0.5,1))
wait(math.random(0.2,0.5))
end
wait()
end
end)
end)
for some reasons, after I came up using this for the bordered zone(which is a cylinder), it stops workings forward. While my old zone which is a square worked. Both has the same script.
Here are videos: -Old zone: https://streamable.com/ce2fml -New zone: https://streamable.com/0v66mz
Or is it just because Roblox updated Touched feature??
Or is it some other script interupting it? Both scripts used in both videos are the same!
If you come up with any solution, please let me know. Thanks for viewing!
TouchEnded and Touched aren’t really reliable for this type of things I’d suggest Region3s so you can detect players in that specific zone by making multiple regions that surround it, if the part that you use for the blue barrier is an union that’s probably the reason it’s not working, unions aren’t totally reliable with collisions.
In addition to what @jcnruad900 said, .Touched and .TouchEnded aren’t really reliable and are more memory extensive than a few other methods. Personally, I use raycasting for detecting which zone a player is in as it is (in my opinion) the most seamless and least memory extensive method.
Hey I’d love to help, with this .Touched can be very unreliable so what I would do is have a Bool Value inside of the player that is set to true when the player is inside of that zone, then set to false upon walking out. After that you can have a script (perhaps in server script service) that is on a “while true do loop” where it constantly checks if the variable is true and if it is then the local player takes damage. Here is an example:
local isInZone = -- put wherever the bool value will be located here
while true do
wait(0.1) -- reduces lag
if isInZone.Value = true then
game.Players.LocalPlayer -- put your hurt code here
end
end
My apologies, I did not notice. What I would do is keep the Bool Value idea in mind, but don’t use .Touch events from the player to activate it, since there are so many ways that can fail. One way to fix this is to create and weld an invisible hitbox around the player that activates it upon touching the zone since it is just one part it will have much better results. Sorry for the misunderstanding, hope this helps!