You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to detect when the model of the character is not touching the part
What is the issue? Include screenshots / videos if possible!
I do not know how to go about that!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have searched online and haven’t found a way to do this
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Script if it helps:
Part=script.Parent
hitBox=Part.Parent.hitBox
hitBox.Touched:Connect(function(hit)
if hit.Parent.FindFirstChild("Humanoid") then
player=game.Players:GetPlayerFromCharacter(hit.Parent)
player:WaitForChild("OV").StrAreaMulti.Value=2
end
end)
hitBox.TouchEnded:Connect(function(hit)--causes the area multi to immediately switch to 1
if hit.Parent.FindFirstChild("Humanoid") then
player=game.Players:GetPlayerFromCharacter(hit.Parent)
player:WaitForChild("OV").StrAreaMulti.Value=1
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Okay, so I have re-written your code, and the main issue I found was that your use of variables, which is more like a personal nitpick but the use of FindFirstChild is incorrect. Please try the script I have provided below and let me know if it works or not!
local Part = script.Parent
local HitBox = Part.Parent.HitBox
HitBox.Touched:Connect(function (hit)
if hit.Parent:FindFirstChild('Humanoid') then
local PlayerFromTouch = game.Players[hit.Parent.Name]
PlayerFromTouch:WaitForChild('OV').StrAreaMulti.Value = 2
end
end)
HitBox.TouchEnded:Connect(function(hit)--causes the area multi to immediately switch to 1
if hit.Parent:FindFirstChild("Humanoid") then
local PlayerFromTouch = game.Players[hit.Parent]
PlayerFromTouch:WaitForChild("OV").StrAreaMulti.Value = 1
end
end)
i am aware that the developer site has included a reference manual for the “TouchEnded” event, but I would like to know a way for it to work for models! The reason is because I needed to know when the player left the zone( stopped touching the hitbox) to set the multi back to one.
local Part = script.Parent
local HitBox = Part.Parent.HitBox
HitBox.Touched:Connect(function (hit)
if hit.Parent:FindFirstChild('Humanoid') then
local PlayerFromTouch = game.Players[hit.Parent.Name]
PlayerFromTouch:WaitForChild('OV').StrAreaMulti.Value = 2
end
end)
HitBox.TouchEnded:Connect(function(hit)--causes the area multi to immediately switch to 1
if hit.Parent:FindFirstChild("Humanoid") then
local PlayerFromTouch = game.Players[hit.Parent.Name]
PlayerFromTouch:WaitForChild("OV").StrAreaMulti.Value = 1
end
end)
local Part = script.Parent
local HitBox = Part.Parent.HitBox
HitBox.Touched:Connect(function (hit)
if hit.Parent:FindFirstChild('Humanoid') then
local PlayerFromTouch = game.Players[hit.Parent.Name]
PlayerFromTouch:WaitForChild('OV').StrAreaMulti.Value = 2
end
end)
HitBox.TouchEnded:Connect(function(hit)--causes the area multi to immediately switch to 1
if hit.Parent:FindFirstChild("Humanoid") then
local PlayerFromTouch = game.Players[hit.Parent.Name]
PlayerFromTouch:WaitForChild("OV").StrAreaMulti.Value = 1
end
end)
This has the same problem that I listed in the comments of the code. The touch ended undoes the multi increase! I’ll try to implement your solution* not allus_ion’s now! I’ll still be periodically check on this thread