Hello there, I was making a terminal script for a group. While making the script I encountered issues that I can't solve them. The script is a NormalScript and It is Inside a model called as RaidSystem whos Parent is the Workspace. Inside the model is a part called as RaidSystemV1 (which is the beam), and finally inside the part the script is there named as Script. The code is given below:
timeuntilwin = 1200
totaltime = 1200
raidteamcolor = "Bright red"
defendteamcolor = "Bright orange"
h = Instance.new("Hint")
h.Parent = game.Workspace
h.Text = "No raid is going on currently."
function OnTouched(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil then
if game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor == BrickColor.new(raidteamcolor) then
script.Parent.BrickColor = BrickColor.new(raidteamcolor)
wait(-1)
timeuntilwin = totaltime
end
if game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor == BrickColor.new(defendteamcolor) then
script.Parent.BrickColor = BrickColor.new(defendteamcolor)
wait(-1)
timeuntilwin = totaltime
end
end
end
script.Parent.Touched:connect(OnTouched)
while true do
wait()
if script.Parent.BrickColor == BrickColor.new(raidteamcolor) then
h.Text = "Raiders win in".." "..timeuntilwin
if timeuntilwin <= totaltime and timeuntilwin > 0 then
wait(1)
timeuntilwin = timeuntilwin - 1
end
if timeuntilwin == 0 then
h:remove()
winmsg = Instance.new("Message")
winmsg.Parent = game.Workspace
winmsg.Text = "Raiders have won!"
wait(5)
winmsg:remove()
script.Parent.BrickColor = BrickColor.new(defendteamcolor)
timeuntilwin = totaltime
end
end
if script.Parent.BrickColor == BrickColor.new(defendteamcolor) then
h.Text = "Defenders win in "..timeuntilwin
if timeuntilwin <=totaltime and timeuntilwin > 0 then
wait (1)
timeuntilwin = timeuntilwin - 1
if timeuntilwin == 0 then
h.Text = "Defenders have won!"
end
end
end
end
[1] The problem I have is that whenever the defending team (Bright Orange team) touches the beam, The Hint message just shows "Defenders will win in 1200". But on the other hand when Raider team (Bright Red team) touches then the Hint message starts to countdown while the defenders hint message does not.
[2] The second problem is that when the Defender touches the beam first and the raiders then touch it, The timer for the raiders starts from 1192 when its supposed to start at 1200.
I am really confused what I have done. If you guys could lend me a hand and help me I would appreciate it. Thank you taking your time into reading this and helping me. :)
