Here is the easier way. 1 script. Server Script in the part.
script.Parent.Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p then
local ui = p.PlayerGui.Cold.Frame
if ui.Visible then
for i = 10, 0, -1 do
ui.TextLabel.Text = "Dangerous area turn around! - "..i.."s"
wait(1)
end
p.Humanoid.Health -= 500
else
ui.TextLabel.Text = "Dangerous area turn around! - 10s"
end
end
end)
script.Parent.Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p then
local ui = p.PlayerGui.Cold.Frame
if ui.Visible then
for i = 10, 0, -1 do
ui.TextLabel.Text = "Dangerous area turn around! - "..i.."s"
wait(1)
end
p.Humanoid.Health -= 500
else
ui.TextLabel.Text = "Dangerous area turn around! - 10s"
end
end
end)
Also why are we ending the script before killing the humanoid? Wouldn’t that render the countdown useless?
local event = game:GetService("ReplicatedStorage").Activator
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
event:FireClient(plr)
end
end)
local script in part
local p = game.Players.LocalPlayer
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local ui = p.PlayerGui.Cold.Frame
if ui.Visible then
for i = 10, 0, -1 do
ui.TextLabel.Text = "Dangerous area turn around! - "..i.."s"
wait(1)
end
p.Humanoid.Health -= 500
else
game.StarterGui.Cold.Frame.TextLabel.Text = "Dangerous area turn around! - 10s"
end
end
end)
First of all the local script shouldn’t be in the part if you read the instructions but the easy way there was something I messed up on here is the script that should work:
script.Parent.Touched:Connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
if p then
local ui = p.PlayerGui.Cold.Frame
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)
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)