Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 06 May 2016 05:29 PM |
Ok so this code keeps breaking and sending no errors, any help?
--Dig script by phonicz function hit() if hit.Parent:FindFirstChild("Humanoid") then local playerName = hit.Parent.Name local player = game.Players:FindFirstChild(hit.Parent.Name) local gui = game.ServerStorage.DigGui --local wait_time = 5 gui.Parent = player.PlayerGui --wait(wait_time) while 1+1 == 2 do
if player.PlayerGui.DigGui.Mode == 0 then print("Player not digging, Deleting in 4 seconds") wait(4) gui:Destroy() end if player.PlayerGui.DigGui.Mode == 1 then print("Digging.... Not deleting yet....") if player.PlayerGui.DigGui.Mode == 2 then print("Player is done digging, deleting in 2 seconds") wait(2) gui:Destroy() end end end end end script.Parent.Touched:connect(function(hit)
|
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 06 May 2016 05:30 PM |
EDIT:
--Dig script by phonicz function hit() if hit.Parent:FindFirstChild("Humanoid") then local playerName = hit.Parent.Name local player = game.Players:FindFirstChild(hit.Parent.Name) local gui = game.ServerStorage.DigGui --local wait_time = 5 gui:Clone() gui.Parent = player.PlayerGui --wait(wait_time) while 1+1 == 2 do
if player.PlayerGui.DigGui.Mode == 0 then print("Player not digging, Deleting in 4 seconds") wait(4) gui:Destroy() end if player.PlayerGui.DigGui.Mode == 1 then print("Digging.... Not deleting yet....") if player.PlayerGui.DigGui.Mode == 2 then print("Player is done digging, deleting in 2 seconds") wait(2) gui:Destroy() end end end end end script.Parent.Touched:connect(function(hit)
|
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
| |
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
| |
|
Rakonus
|
  |
| Joined: 19 Dec 2014 |
| Total Posts: 1004 |
|
|
| 07 May 2016 08:43 AM |
What is DigGui?
https://api.roblox.com/My/Balance |
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 07 May 2016 08:45 AM |
| DigGui is just the gui it is attempting to clone into the player who touched the part. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 07 May 2016 08:47 AM |
"while 1+1 == 2 do"
Don't do that.
while true do
|
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 07 May 2016 08:52 PM |
| Then what, It still seems to not work. |
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
| |
|
|
| 08 May 2016 05:20 PM |
error, the loop never ends.
|
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 08 May 2016 05:22 PM |
Is that the only thing I need to fix? Like doing:
While true do
instead of:
while 1 + 1 == 2 do |
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 09 May 2016 10:22 AM |
Edit: Still need help, I remade the code:
--Dig script by phonicz function hit() if hit.Parent:FindFirstChild("Humanoid") then local playerName = hit.Parent.Name local player = game.Players:FindFirstChild(hit.Parent.Name) local gui = game.ServerStorage.DigGui --local wait_time = 5 gui.Parent = player.PlayerGui --wait(wait_time) while true do
if player.PlayerGui.DigGui.Mode == 0 then print("Player not digging, Deleting in 4 seconds") wait(4) gui:Destroy() end if player.PlayerGui.DigGui.Mode == 1 then print("Digging.... Not deleting yet....") if player.PlayerGui.DigGui.Mode == 2 then print("Player is done digging, deleting in 2 seconds") wait(2) gui:Destroy() end end end end end script.Parent.Touched:connect(function(hit) |
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
| |
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 09 May 2016 10:36 AM |
I recommend using http://wiki.roblox.com/index.php?title=API:Class/Players/GetPlayerFromCharacter
instead of "game.Players:FindFirstChild(hit.Parent.Name)"
Also
"script.Parent.Touched:connect(function(hit)" --99% sure this is your issue
Try
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local playerName = hit.Parent.Name local player = game.Players:FindFirstChild(hit.Parent.Name) local gui = game.ServerStorage.DigGui --local wait_time = 5 gui.Parent = player.PlayerGui --wait(wait_time) while true do
if player.PlayerGui.DigGui.Mode == 0 then print("Player not digging, Deleting in 4 seconds") wait(4) gui:Destroy() end if player.PlayerGui.DigGui.Mode == 1 then print("Digging.... Not deleting yet....") if player.PlayerGui.DigGui.Mode == 2 then print("Player is done digging, deleting in 2 seconds") wait(2) gui:Destroy()
end end end end end)
Not tested but in theory should work. |
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 09 May 2016 10:52 AM |
Shows the gui, But now the code for clicking to change the text on the gui will not work.
Code for clicking on the gui to make it change the text.
function click() script.Parent.Parent.Mode = 1 script.Parent.Text = "Digging." wait(0.25) script.Parent.Text = "Digging.." wait(0.25) script.Parent.Text = "Digging..." wait(0.25) script.Parent.Text = "Digging." wait(0.25) script.Parent.Text = "Digging.." wait(0.25) script.Parent.Text = "Digging..." wait(0.25) script.Parent.Text = "Digging." wait(0.25) script.Parent.Text = "Digging.." wait(0.25) script.Parent.Text = "Digging..." wait(0.25) script.Parent.Text = "Digging." wait(0.25) script.Parent.Text = "Digging.." wait(0.25) script.Parent.Text = "Digging..." wait(0.25) script.Parent.Text = "Digging." wait(0.5) script.Parent.Text = "Done" script.Parent.Parent.Mode = 2 wait(3)
end
script.Parent.MouseButton1Down:connect(click) |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 09 May 2016 10:58 AM |
I don't see anything that would break that.
Make sure "script.Parent" is a Gui Button. |
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 09 May 2016 11:41 AM |
| script.Parent is a textbutton |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 09 May 2016 11:42 AM |
| Where does it error? If it doesn't error, than check if the script is disabled or not. |
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 09 May 2016 11:49 AM |
| It does not say an error, It just stops and does not do anything when the textbutton is clicked. |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 09 May 2016 11:51 AM |
| So it's running up to a certain point and stopping without error? |
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 09 May 2016 11:58 AM |
| The previous code to display the gui works, but the gui code to click and change the text does not work |
|
|
| Report Abuse |
|
|
|
| 09 May 2016 12:06 PM |
function hit() if hit.Parent:FindFirstChild("Humanoid") then local playerName = hit.Parent.Name local player = game.Players:FindFirstChild(hit.Parent.Name) local gui = game.ServerStorage.DigGui --local wait_time = 5 gui.Parent = player.PlayerGui --wait(wait_time) while 1+1 == 2 do
if player.PlayerGui.DigGui.Mode == 0 then print("Player not digging, Deleting in 4 seconds") wait(4) gui:Destroy() end if player.PlayerGui.DigGui.Mode == 1 then print("Digging.... Not deleting yet....") if player.PlayerGui.DigGui.Mode == 2 then print("Player is done digging, deleting in 2 seconds") wait(2) gui:Destroy() end end end end end script.Parent.Touched:connect(hit)
--You shouldn't have had that extra "function(hit)" at the connection. Just leave it as "script.Parent.Touched:connect(hit)". |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 09 May 2016 12:14 PM |
--function hit()--When you use hit in the code you're trying to call the function...
--Use this: function DigGui(hit) if hit.Parent:FindFirstChild'Humanoid' and game.Players:FindFirstChild(hit.Parent.Name) then local p = game.Players:FindFirstChild(hit.Parent.Name) local gui = game.ServerStorage.DigGui:Clone() gui.Parent = p.PlayerGui while wait() do if p.PlayerGui.DigGui.Mode == 0 then print'Player not digging, Deleting in 4 seconds' wait(4) gui:Destroy() end if p.PlayerGui.DigGui.Mode == 1 then print'Digging, not deleted yet...' if p.PlayerGui.DigGui.Mode == 2 then wait(2) gui:Destroy() print(p.Name..' is done digging.') --To stop the loop so it won't keep looping once the script is done. break end end end end end
|
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 09 May 2016 12:20 PM |
--Also use this for your click script:
function click() local sp = script.Parent script.Parent.Parent.Mode = 1 for i = 1, 14 do wait(0.25) local num = math.random(1,3) if num == 1 then sp.Text = 'Digging.' elseif num == 2 then sp.Text = 'Digging..' elseif num == 3 then sp.Text = 'Digging...' end end script.Parent.Parent.Mode = 2 wait(3) end
|
|
|
| Report Abuse |
|
|
Phonicz
|
  |
| Joined: 10 Apr 2010 |
| Total Posts: 400 |
|
|
| 09 May 2016 12:29 PM |
Used your code devvince and it does not give me the gui.
Game to look at it: https://www.roblox.com/games/398720859/Warrior-Cats-NEW-Lake-Territory |
|
|
| Report Abuse |
|
|