j818
|
  |
| Joined: 10 May 2008 |
| Total Posts: 344 |
|
|
| 02 Jul 2014 03:37 AM |
So I have this script, and it has text, I want the text to change, according to the stats. For example if you want on the text brick and you have less than 10 gold, it will say "You dont have enough gold" If you walk on it with more than 10 gold, it would say "Ok, you have enough gold"
Here is the very broken script:
function message(m)
m.Text = "Hi" wait(2)
m.Text = "I will give you the code if you give me 10 gold" wait(2) local player = getPlayer(human)
debounce = true if (player == nil) then return end local stats = player:findFirstChild("leaderstats") local sp = stats:findFirstChild("Gold") if sp == nil then return false end if (sp.Value >= 10) then m.Text = "Ok thank you. The code is 1874" if (sp.Value <10) then m.Text = "You dont have enough gold to recieve the code" end
end
end function onTouch(hit)
--NOT BROKEN UNDER THIS POINT
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then local player = game.Players:FindFirstChild(hit.Parent.Name)
if player:FindFirstChild("PlayerGui"):FindFirstChild("ScreenGui") == nil then sg = Instance.new("ScreenGui") sg.Parent = player:FindFirstChild("PlayerGui") end
if player.PlayerGui.ScreenGui:FindFirstChild("MessageBox") == nil then
local f = Instance.new("Frame") f.Name = "MessageBox" f.Position = UDim2.new(0.3, 0, 0.1, 0) f.Size = UDim2.new(0.4, 0, 0, 50) f.Style = "RobloxRound" f.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
local m = Instance.new("TextLabel") m.Position = UDim2.new(0.5, 0, 0.5, 0) m.FontSize = "Size14" m.TextColor3 = Color3.new(1,1,1) m.Parent = f
message(m)
f:Destroy() end end end end
script.Parent.Touched:connect(onTouch)
|
|
|
| Report Abuse |
|
|
Ozerit
|
  |
| Joined: 28 Jun 2014 |
| Total Posts: 133 |
|
|
| 02 Jul 2014 04:50 AM |
Did you implement Debounce correctly?
Debounce should be
Debounce = false
something(function() if Debounce then return end Debounce = true code code code Dounce = false end)
If my eyes are correct, you just have Debounce set to true, and that wont do much. Maybe that is affecting your script?
I have the swag. |
|
|
| Report Abuse |
|
|
Ozerit
|
  |
| Joined: 28 Jun 2014 |
| Total Posts: 133 |
|
|
| 02 Jul 2014 04:53 AM |
try this:
Debounce = false function message(m) if Debounce then return end
m.Text = "Hi" wait(2)
m.Text = "I will give you the code if you give me 10 gold" wait(2) local player = getPlayer(human)
Debounce = true if (player == nil) then return end local stats = player:findFirstChild("leaderstats") local sp = stats:findFirstChild("Gold") if sp == nil then return false end if (sp.Value >= 10) then m.Text = "Ok thank you. The code is 1874" if (sp.Value <10) then m.Text = "You dont have enough gold to recieve the code" Debounce = false end
end
end function onTouch(hit)
--NOT BROKEN UNDER THIS POINT
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then local player = game.Players:FindFirstChild(hit.Parent.Name)
if player:FindFirstChild("PlayerGui"):FindFirstChild("ScreenGui") == nil then sg = Instance.new("ScreenGui") sg.Parent = player:FindFirstChild("PlayerGui") end
if player.PlayerGui.ScreenGui:FindFirstChild("MessageBox") == nil then
local f = Instance.new("Frame") f.Name = "MessageBox" f.Position = UDim2.new(0.3, 0, 0.1, 0) f.Size = UDim2.new(0.4, 0, 0, 50) f.Style = "RobloxRound" f.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
local m = Instance.new("TextLabel") m.Position = UDim2.new(0.5, 0, 0.5, 0) m.FontSize = "Size14" m.TextColor3 = Color3.new(1,1,1) m.Parent = f
message(m)
f:Destroy() end end end end
script.Parent.Touched:connect(onTouch)
this probably wont work, but you never know.
I have the swag. |
|
|
| Report Abuse |
|
|
Ozerit
|
  |
| Joined: 28 Jun 2014 |
| Total Posts: 133 |
|
|
| 02 Jul 2014 05:01 AM |
plz update
I have the swag. |
|
|
| Report Abuse |
|
|
j818
|
  |
| Joined: 10 May 2008 |
| Total Posts: 344 |
|
| |
|
Ozerit
|
  |
| Joined: 28 Jun 2014 |
| Total Posts: 133 |
|
|
| 02 Jul 2014 05:06 AM |
Eh, I tried. I suck at scripting, but I'm pretty confident about where I implemented the Debounce.
I have the swag. |
|
|
| Report Abuse |
|
|
j818
|
  |
| Joined: 10 May 2008 |
| Total Posts: 344 |
|
| |
|
j818
|
  |
| Joined: 10 May 2008 |
| Total Posts: 344 |
|
| |
|
j818
|
  |
| Joined: 10 May 2008 |
| Total Posts: 344 |
|
| |
|
j818
|
  |
| Joined: 10 May 2008 |
| Total Posts: 344 |
|
|
| 02 Jul 2014 10:16 PM |
| Nobody knows how to fix this? |
|
|
| Report Abuse |
|
|
j818
|
  |
| Joined: 10 May 2008 |
| Total Posts: 344 |
|
| |
|
|
| 02 Jul 2014 11:46 PM |
Debounce = false local HitP = nil
function message(m) if Debounce then return end
m.Text = "Hi" wait(2)
m.Text = "I will give you the code if you give me 10 gold" wait(2) local player = HitP
Debounce = true if (player == nil) then return end if player:FindFirstChild("leaderstats") then local stats = player:findFirstChild("leaderstats") if stats and stats:FindFirstChild("Gold") then local sp = stats:findFirstChild("Gold") if stats and sp then if (sp.Value >= 10) then m.Text = "Ok thank you. The code is 1874" wait(4) elseif (sp.Value <10) then m.Text = "You dont have enough gold to recieve the code" wait(4) end
end
end end Debounce = false end
script.Parent.Touched:connect(function(hit)
--NOT BROKEN UNDER THIS POINT
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then local player = game.Players:FindFirstChild(hit.Parent.Name) HitP = game.Players:FindFirstChild(hit.Parent.Name)
if player:FindFirstChild("PlayerGui"):FindFirstChild("ScreenGui") == nil then sg = Instance.new("ScreenGui") sg.Parent = player:FindFirstChild("PlayerGui") end
if player.PlayerGui.ScreenGui:FindFirstChild("MessageBox") == nil then
local f = Instance.new("Frame") f.Name = "MessageBox" f.Position = UDim2.new(0.3, 0, 0.1, 0) f.Size = UDim2.new(0.4, 0, 0, 50) f.Style = "RobloxRound" f.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
local m = Instance.new("TextLabel") m.Position = UDim2.new(0.5, 0, 0.5, 0) m.FontSize = "Size14" m.TextColor3 = Color3.new(1,1,1) m.Parent = f
message(m)
f:Destroy() end end end end)
-- Please note: I did not add the gold reduction. So you're gonna have to add it yourself. You should be able to handle it. |
|
|
| Report Abuse |
|
|
j818
|
  |
| Joined: 10 May 2008 |
| Total Posts: 344 |
|
|
| 02 Jul 2014 11:57 PM |
| Yup, I added the reduction. It worked. Thanks! :) |
|
|
| Report Abuse |
|
|
| |
|