generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Help fix this please?-------------------------

Previous Thread :: Next Thread 
j818 is not online. 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 is not online. 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 is not online. 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 is not online. Ozerit
Joined: 28 Jun 2014
Total Posts: 133
02 Jul 2014 05:01 AM
plz update

I have the swag.
Report Abuse
j818 is not online. j818
Joined: 10 May 2008
Total Posts: 344
02 Jul 2014 05:05 AM
Didnt work. :(

Report Abuse
Ozerit is not online. 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 is not online. j818
Joined: 10 May 2008
Total Posts: 344
02 Jul 2014 05:56 AM
Bump
Report Abuse
j818 is not online. j818
Joined: 10 May 2008
Total Posts: 344
02 Jul 2014 03:43 PM
Bump D:
Report Abuse
j818 is not online. j818
Joined: 10 May 2008
Total Posts: 344
02 Jul 2014 04:54 PM
Bump Again..?
Report Abuse
j818 is not online. j818
Joined: 10 May 2008
Total Posts: 344
02 Jul 2014 10:16 PM
Nobody knows how to fix this?
Report Abuse
j818 is not online. j818
Joined: 10 May 2008
Total Posts: 344
02 Jul 2014 11:29 PM
Bump
Report Abuse
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
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 is not online. j818
Joined: 10 May 2008
Total Posts: 344
02 Jul 2014 11:57 PM
Yup, I added the reduction. It worked. Thanks! :)
Report Abuse
ninjaxrasx is not online. ninjaxrasx
Joined: 29 May 2008
Total Posts: 757
03 Jul 2014 12:01 AM
Glad I could help. :)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image