|
| 22 Sep 2014 04:01 PM |
I'm attempting to make a 'pressure plate', you could call it. I want to be able to make a part that acts like a pressure plate when a ROBLOXian on the "Raiders" team steps onto it. Once they step onto it, the plate triggers a timer set at 330 seconds, which I have in a SurfaceGui. The timer is located above the plate. I also want the timer to start over at 330 seconds if the ROBLOXian steps off of the plate (or part), or if they die. How do I do this?
Here's what I have for the pressure plate so far: __________________________________________________________
Raiders = "Bright red" TFC = "Earth green" script.Parent:WaitForChild("Touch") script.Parent:WaitForChild("Timer") script.Parent:WaitForChild("Holder") coroutine.resume(coroutine.create(function() script.Parent.Touch.Touched:connect(function(on) if on and on.Parent and on.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(on.Parent) if plr and plr.TeamColor == plr.TeamColor.Name == Raiders then for _,a in pairs(script.Parent:GetChildren()) do end end end end) end)) __________________________________________________________
Here's what I have for the timer so far: __________________________________________________________
local sp = script.Parent
local Stopped = false --Make something to change this to true when they step out of the boundary
local countdown = sp:WaitForChild("Timer")
function offboundary(off) local humanoid = off.Parent:FindFirstChild("Humanoid") if not humanoid then local Stopped = true end end while false do while true do local time = 300 --Change this to how many seconds till zero. for i = 300,0,-1 do --Change the number after the comma to the one you have above. if not Stopped then wait(1) time = i script.Parent.Text = tostring(time) end end end end ___________________________________________________
The timer script is inside of a TextLabel (I renamed it 'TimeText'), and the TextLabel is inside of the SurfaceGui. ___________________________________________________
The scripts don't work properly, so don't be afraid to correct me on what I'm doing wrong. I just went into LUA last Friday. |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2014 04:11 PM |
| A response would be appreciated. |
|
|
| Report Abuse |
|
|
Vescatur
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 3426 |
|
|
| 22 Sep 2014 04:16 PM |
You gave us 10 minutes.
If we want to know how to fix the errors and such, we'll have to setup a mock situation to mimic this, take the scripts, insert them in, test, figure out the errors, fix the errors, write out an explanation, etc..
Give us more time. |
|
|
| Report Abuse |
|
|
Nyxis
|
  |
| Joined: 15 Nov 2012 |
| Total Posts: 3374 |
|
|
| 22 Sep 2014 04:19 PM |
| 2 wooden blocks next to each other in a horizontal fashion in your crafting bench. |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2014 04:24 PM |
I apologize. Take your time.
No, I'm not talking about Minecraft. |
|
|
| Report Abuse |
|
|
Nyxis
|
  |
| Joined: 15 Nov 2012 |
| Total Posts: 3374 |
|
|
| 22 Sep 2014 04:26 PM |
| xD I've been playing it recently though. )': |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2014 04:28 PM |
| It's a great game, I wasn't referring to it, however. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 22 Sep 2014 04:51 PM |
Using Touched and TouchEnded:
touching = 0
script.Parent.Touched:connect(function() touching = touching + 1 while touching > 0 do --countdown end end)
script.Parent.TouchEnded:connect(function() touching = touching - 1 end) |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2014 05:06 PM |
| It say on line 1 that a '=' was expected near Touched. |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2014 05:07 PM |
| Is "Using Touched and TouchedEnded:" part of the script? |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2014 06:03 PM |
| Can someone tell me how to do this? |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 25 Sep 2014 03:32 PM |
| A good idea is to code a new solution with your new found Touched/TouchEnded knowledge |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 25 Sep 2014 03:44 PM |
Touched and Touchended is two things you combine to make a script that functions WHILE you are on something, like a pressure plate would, while you step on it, it goes abit down and triggers something.
script.Parent.Touched:connect(function(hit) ---Whats going to happen when he touches it end)
script.Parent.TouchEnded:connect(function() ----End what you did in the touched event, this is for when you step off the plate end) |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2014 04:02 PM |
I understand what the Touched event does, thank you for the assistance on that. However, it still won't work properly.
On the boundary I have: _________________________________________________
Raiders = "Bright red"
TFC = "Earth green"
local timer = workspace["Power Core 1"].Board.SurfaceGui.TimeText
script.Parent:WaitForChild("Touch")
script.Parent.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr and plr.TeamColor == plr.TeamColor.Name == Raiders then for _,a in pairs(script.Parent:GetChildren()) do local timer = true end script.Parent.TouchEnded:connect(function() local timer = false ----End what you did in the touched event, this is for when you step off the plate end) end end end) __________________________________________________
On the timer I have: __________________________________________________
local sp = script.Parent
while false do while true do local time = 330 --Change this to how many seconds till zero. for i = 330,0,-1 do --Change the number after the comma to the one you have above. time = i script.Parent.Text = tostring(time) end end end __________________________________________________
I don't believe I'm connecting the scripts correctly. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 25 Sep 2014 04:13 PM |
RaiderTeamColor = "COLORHERE" ---- put the color for the raider team here
script.Parent.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr.TeamColor == RaiderTeamColor then ---timerstuff end end end)
script.Parent.TouchEnded:connect(function() ---make the timer count down or go away or something, this is for when you leave the touching end) |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2014 05:22 PM |
use magnitude >:l unless you're going to remove the animations of the character, i suggest you don't use the touched function |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 25 Sep 2014 05:26 PM |
| Magnitude is a biiiig nooooo |
|
|
| Report Abuse |
|
|
pivot513
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 328 |
|
|
| 25 Sep 2014 06:04 PM |
| Try stone slabs instead. They're a bit bigger. |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2014 06:28 PM |
I found that you can disable and enable a script with script.Parent, so I decided to use this method. It's what I'm trying to do, enable the timer. So here's what I have.
In the Script inside of my boundary contains: _____________________________________________________
RaiderTeamColor = "Bright red" ---- put the color for the raider team here
script.Parent.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr.TeamColor == RaiderTeamColor then
script.Parent.Parent.Parent.Timer.Disabled = false
end end end)
script.Parent.TouchEnded:connect(function() script.Parent.Parent.TimeText.Timer.Disabled = true ---make the timer count down or go away or something, this is for when you leave the touching end) _______________________________________________________
Renamed "Timer", the Script inside of the SurfaceGui contains: _______________________________________________________
local sp = script.Parent
local time = 330 --Change this to how many seconds till zero. for i = 1, 330 do --Change the number after the comma to the one you have above. wait(1) time = time - 1 script.Parent.Text = tostring(time) end _______________________________________________________
Now, when disabled = false, I want the timer to run. Output tells me as soon as I step onto the boundary, when I'm testing the game, this, " Disconnected event because of exception". What's the exception. I'm on the raiders team when I step onto the boundary. |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2014 06:35 PM |
Here's where it's breaking:
script.Parent.Parent.TimeText.Timer.Disabled = true
Debugger says, "TimeText is not a valid member of Model."
TimeText is a TextLabel, renamed. Timer is a script renamed.
|
|
|
| Report Abuse |
|
|
|
| 25 Sep 2014 06:57 PM |
| Assistance would be appreciated. |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2014 07:07 PM |
Here's where it's breaking:
script.Parent.Parent.TimeText.Timer.Disabled = true
Debugger says, "TimeText is not a valid member of Model."
TimeText is a TextLabel, renamed. Timer is a script renamed. Why does Debugger say what it does? |
|
|
| Report Abuse |
|
|