But since where you set the visibility to true it was using starter GUI and not player GUI so it wont affect anything.
I have fixed that now in my script.
Looking at this It has confused me. So I’ll tell you what I’ve done so far and what script types I’m using.
Script In Part:
Local Script In Part too
This I didn’t quite understand so I made it:
game.ReplicatedStorage.Activator.OnClientEvent:Connect(function(player)
end)
For:
Changing the name of scripts to make this easier to understand:
So the one I said is easier:
should work (and it’s only that one script you won’t need the other scripts for the easier one), does it not?
So what I was saying is remove the local script from the part and put everything except for the touched event inside of the
You got the source what wait() is going to be depricated?
Also curious on where he got that
Try printing p and hit and hit.Parent
print(p, hit, hit.Parent)
Make sure you put that after the p variable
Ah nevermind the prints I realized I forgot to add the line that makes it visible her you go:
script.Parent.Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p then
local ui = p.PlayerGui.Cold.Frame
ui.Visible = true
if ui.Visible then
for i = 10, 0, -1 do
ui.TextLabel.Text = "Dangerous area turn around! - "..i.."s"
wait(1)
end
hit.Parent.Humanoid.Health -= 500
else
ui.TextLabel.Text = "Dangerous area turn around! - 10s"
end
end
end)
before i test that out, shouldnt i change these around? otherwise we end the script before killing
No that end is for the countdown loop if you put the killing inside the loop then it will kill after the first second aka every time the loop runs.
That should work. I’m sorry but I have to go now!
Now it works perfectly besides this one issue:
I do appreciate the amount of help you’ve given, its really helped out. And anyone else that helped too <3
script.Parent.Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p then
local ui = p.PlayerGui.Cold.Frame
ui.Visible = true
if ui.Visible then
for i = 10, 0, -1 do
ui.TextLabel.Text = "Dangerous area turn around! - "..i.."s"
wait(1)
end
hit.Parent.Humanoid.Health -= 500
else
ui.TextLabel.Text = "Dangerous area turn around! - 10s"
end
end
end)
Issue is
- Still counts down even off the “dangerous area”
- It stacks - Meaning I can just spam those dangerous area UIs and they all count down then kill me.
I have time for one more reply make sure to add a check to check if the player is still touching the part
Ok I will try finding out how linking back to cooldowns:
OPEN GUI with a PART - Roblox Scripting Tutorial - YouTube
Use touchended and have variable called touching when the player touches set touching to true when touchended set touching to false
Yes.
Fixed the stacked issue:
However I am still confused on how to detect when players are no longer on the part, so if anyone can help me detect when users are off the part then end the kill script, that would be appreciated. Unless I need to revert back to the singular typing out and detected if p is false?
local debounce = true
local par = script.Parent
script.Parent.Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p then
local ui = p.PlayerGui.Cold.Frame
if debounce and hit.Parent:FindFirstChildWhichIsA("Humanoid") then
debounce = false
ui.Visible = true
if ui.Visible then
for i = 10, 0, -1 do
ui.TextLabel.Text = "Dangerous area turn around! - "..i.."s"
wait(1)
end
hit.Parent.Humanoid.Health -= 500
wait(1)
debounce = true
ui.Visible = false
else debounce = true
ui.TextLabel.Text = "Dangerous area turn around! - 10s"
ui.Visible = false
end
end
end
end)
Issue is:
- The UI doesn’t stop when the humanoid is off the kill part.
So what I was saying setup a variable called touching:
local touching = false
When you touch the part set touching to true
Then setup a touch ended:
script.Parent.TouchEnded:Connect(function()
touching = false
end)
Then in the loop in the touched event add a check to check if touching is false
So:
for i = 10, 0, -1 do
ui.TextLabel.Text = "Dangerous area turn around! - "..i.."s"
if not touching then break end
wait(1)
end
Final:
local touching = false
script.Parent.Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p then
local ui = p.PlayerGui.Cold.Frame
if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
touching = true
ui.Visible = true
if ui.Visible then
for i = 10, 0, -1 do
ui.TextLabel.Text = "Dangerous area turn around! - "..i.."s"
if not touching then break end
wait(1)
end
hit.Parent.Humanoid.Health -= 500
ui.Visible = false
else
ui.TextLabel.Text = "Dangerous area turn around! - 10s"
ui.Visible = false
end
end
end
end)
script.Parent.TouchEnded:Connect(function()
touching = false
end)
I mean I made one called ‘debounce’ instead, could I put:
script.Parent.TouchEnded:Connect(function()
touching = false
end)
Before line 2?
I’m not really sure what your asking but try what I wrote because I just edited the reply