Well your method still tries to set the gui for any player thst touches the ares in a local script. I mean like every player instead of just the local player
Please show me where that is happening so I can help by removing it.
Hey, nothing works still and I tested it and nothing works. I am using a localscript and putting it inside of the gui. I don’t know if thats the problem butI don’t know how else to say it.
Wait nvm it doesn’t. But the local script re runs every time the player dies. But the connection doesn’t get disconnect leading to a memory leak.
Did you change the variable called hitbox?
Yes, and here is another example of a sound region box. I don’t know if it will help but here it is. It’s basically the same thing except it plays sound.
local SoundRegionsWorkspace = game.Workspace:WaitForChild("SoundRegions")
local Found = true
while wait(1)do
for i, v in pairs(SoundRegionsWorkspace:GetChildren())do
Found = false
local region = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))
local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts)do
-- Loop thingie
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
print('Player was found')
Found = true
break
else
Found = false
print('Player was not found in region')
end
end
if Found == true then
-- Start playing music
if script.Parent.SoundRegions[v.Name].IsPlaying == false then
script.Parent.SoundRegions[v.Name]:Play()
break
end
else
script.Parent.SoundRegions[v.Name]:Stop()
end
end
end
Also it is a LocalScript.
Forgot to mention that you repeat the same code twice.
The CharacterAdded doesnt fire when it was connected so you need to run it after Because, else it has to wait for the players character to remove itself and readd itself. I will still try to make it more readable
Then just change this line
local char = plr.Character
to this
local char = plr.Character or plr.CharcterAdded:Wait()
This waits when the character is available
meaning you can remove the CharacterAdded Connection set previously in your script.
I will be remaking the localscript. Hopefully it works this time.
Be sure to use task.wait() instead of wait() aswell.
I will be taking that into consideration. Thanks
Can I get a little bit more info on what you’re trying to get as a result? Since, your code says that if the player is in the zone, it should show the text and after 1 second it hides the text, “smoothly” (you should be making it with tweenservice and not for loops).
@benny_boi2356 I have remade the whole localscript it should be placed inside of the GUI in startergui:
local function isInside(position1, position2, size2)
return (position1.X >= position2.X - size2.X / 2 and position1.X <= position2.X + size2.X / 2) and -- X Axis
(position1.Y >= position2.Y - size2.Y / 2 and position1.Y <= position2.Y + size2.Y / 2) and -- Y Axis
(position1.Z >= position2.Z - size2.Z / 2 and position1.Z <= position2.Z + size2.Z / 2)
end
local title = script.Parent.Title
local seconds = 1 -- TIME IN SECONDS YOU WANT IT TO TAKE FOR THE TEXT LABEL TO REACH ITS GOAL.
local area = game:GetService("Workspace").Area
local debounce = false
local Found = true
while true do task.wait()
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
if isInside(char.PrimaryPart.Position, area.Position, area.Size) and not debounce then
debounce = true
print("Player in zone.")
title.Visible = true
title.Parent.Enabled = true
game:GetService("TweenService"):Create(title,TweenInfo.new(seconds),{TextTransparency = 0}):Play()
elseif not isInside(char.PrimaryPart.Position, area.Position, area.Size) and debounce then
debounce = false
game:GetService("TweenService"):Create(title,TweenInfo.new(seconds),{TextTransparency = 1}):Play()
print("Player outside zone.")
end
end
This code is no different than the other one in terms of working. I think I’m just gonna post my post again and you can stop helping because all your code does is detect if the player is inside the zone or outside the zone. If you want to give it one more shot I guess you can but I can guarantee you it won’t work. Thanks for trying I guess.
Please explain what you are actually trying to do. The script you made doesn’t lead me anywhere. Any screenshots maybe you can send the map with the scripts and all so I can understand better what you are trying to accomplish.
This is where the stuff is located. My only goal is to make it appear when the player walks in and fade away then disappear immediately when the player walks out then when the player walks back in it will appear again. Basically just a cycle.
Also, if you actually tested my original code you would’ve seen that it was supposed to fade away even when you’re in the zone.