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: Script.Parent.Frame.Label is invisible?

Previous Thread :: Next Thread 
johny220 is not online. johny220
Joined: 30 Oct 2011
Total Posts: 4584
09 Nov 2014 09:33 AM
wait(1)

local tool = script.Parent
local frame = tool.Frame
local label = frame.Label

function getDist(a, b)
return (a - b).magnitude
end

function getEdible(part)
local val = part:findFirstChild("Edible")
if val ~= nil then
return true
else
return false
end
end

function onMouseMove(mouse)
local targ = mouse.Target

local player = tool.Parent.Parent
local char = player.Character
local head = char.Head

label.Text = ""

if targ ~= nil then
if getEdible(targ) then
if getDist(head.Position, mouse.hit.p) < 15 then
local StrokeColor = script.Parent.Frame.Label.TextStrokeColor3
StrokeColor = targ.Brickcolor -- probably something to do with this
label.Text = targ.Name..", "..targ.Edible.Amnt.Value.." portion(s) left"
end
end
end
end

function modStat(stat, val)
stat.Value = stat.Value + val

if stat.Value > 100 then
stat.Value = 100
end
end

function onSelected(mouse)
local player = tool.Parent.Parent

frame.Parent = player.PlayerGui.ScreenGui

mouse.Move:connect(function() onMouseMove(mouse) end)

mouse.Button1Down:connect(function()
local stats = player.Stats
local char = player.Character
local head = char.Head

local targ = mouse.Target

if targ ~= nil then
if getEdible(targ) then
if getDist(head.Position, mouse.hit.p) < 15 then
local ed = targ.Edible

modStat(stats.Hunger, ed.Hunger.Value)
modStat(stats.Thirst, ed.Thirst.Value)
modStat(stats.Health, ed.Health.Value)

if ed.Amnt.Value > 1 then
ed.Amnt.Value = ed.Amnt.Value - 1
else
targ:remove()
end
end
end
end

onMouseMove(mouse)
end)
end

function onDeselected()
frame.Parent = tool

if example ~= nil then
example.Parent = nil
end
end

tool.Selected:connect(onSelected)
tool.Deselected:connect(onDeselected)


I'm not sure why, but it worked before I added stuff near the note.
Report Abuse
johny220 is not online. johny220
Joined: 30 Oct 2011
Total Posts: 4584
09 Nov 2014 09:35 AM
Ctrl + F "Probably" is where the note is
Report Abuse
johny220 is not online. johny220
Joined: 30 Oct 2011
Total Posts: 4584
09 Nov 2014 09:36 AM
(Updated Script)

wait(1)

local tool = script.Parent
local frame = tool.Frame
local label = frame.Label
local StrokeColor = label.TextStrokeColor3

function getDist(a, b)
return (a - b).magnitude
end

function getEdible(part)
local val = part:findFirstChild("Edible")
if val ~= nil then
return true
else
return false
end
end

function onMouseMove(mouse)
local targ = mouse.Target

local player = tool.Parent.Parent
local char = player.Character
local head = char.Head

label.Text = ""

if targ ~= nil then
if getEdible(targ) then
if getDist(head.Position, mouse.hit.p) < 15 then
StrokeColor = targ.Brickcolor -- probably something to do with this
label.Text = targ.Name..", "..targ.Edible.Amnt.Value.." portion(s) left"
end
end
end
end

function modStat(stat, val)
stat.Value = stat.Value + val

if stat.Value > 100 then
stat.Value = 100
end
end

function onSelected(mouse)
local player = tool.Parent.Parent

frame.Parent = player.PlayerGui.ScreenGui

mouse.Move:connect(function() onMouseMove(mouse) end)

mouse.Button1Down:connect(function()
local stats = player.Stats
local char = player.Character
local head = char.Head

local targ = mouse.Target

if targ ~= nil then
if getEdible(targ) then
if getDist(head.Position, mouse.hit.p) < 15 then
local ed = targ.Edible

modStat(stats.Hunger, ed.Hunger.Value)
modStat(stats.Thirst, ed.Thirst.Value)
modStat(stats.Health, ed.Health.Value)

if ed.Amnt.Value > 1 then
ed.Amnt.Value = ed.Amnt.Value - 1
else
targ:remove()
end
end
end
end

onMouseMove(mouse)
end)
end

function onDeselected()
frame.Parent = tool

if example ~= nil then
example.Parent = nil
end
end

tool.Selected:connect(onSelected)
tool.Deselected:connect(onDeselected)
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
09 Nov 2014 09:36 AM
can you give us just a portion of the code for us to look through rather than your entire script?

it makes it a lot easier for me to help

in case you aren't sure where the problem is, give us a dozen lines or so around the output error
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
09 Nov 2014 09:39 AM
sorry for the latepost

if the mouse.Target is nil, you will get an error

for example if the mouse is pointing at the sky

i'll keep looking for errors
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
09 Nov 2014 09:40 AM
dang stop updating ur making me look stupid

what's the problem in the new script?
Report Abuse
johny220 is not online. johny220
Joined: 30 Oct 2011
Total Posts: 4584
09 Nov 2014 10:00 AM
There's actually NOTHING wrong in the output, that's what's confusing me, and, the entire code is relevant, that's why it's really confusing to fix.
Report Abuse
johny220 is not online. johny220
Joined: 30 Oct 2011
Total Posts: 4584
09 Nov 2014 10:04 AM
Original script, if it helps.

wait(1)

local tool = script.Parent
local frame = tool.Frame
local label = frame.Label

function getDist(a, b)
return (a - b).magnitude
end

function getEdible(part)
local val = part:findFirstChild("Edible")
if val ~= nil then
return true
else
return false
end
end

function onMouseMove(mouse)
local targ = mouse.Target

local player = tool.Parent.Parent
local char = player.Character
local head = char.Head

label.Text = ""

if targ ~= nil then
if getEdible(targ) then
if getDist(head.Position, mouse.hit.p) < 15 then
label.Text = targ.Name..", "..targ.Edible.Amnt.Value.." portion(s) left"
end
end
end
end

function modStat(stat, val)
stat.Value = stat.Value + val

if stat.Value > 100 then
stat.Value = 100
end
end

function onSelected(mouse)
local player = tool.Parent.Parent

frame.Parent = player.PlayerGui.ScreenGui

mouse.Move:connect(function() onMouseMove(mouse) end)

mouse.Button1Down:connect(function()
local stats = player.Stats
local char = player.Character
local head = char.Head

local targ = mouse.Target

if targ ~= nil then
if getEdible(targ) then
if getDist(head.Position, mouse.hit.p) < 15 then
local ed = targ.Edible

modStat(stats.Hunger, ed.Hunger.Value)
modStat(stats.Thirst, ed.Thirst.Value)
modStat(stats.Health, ed.Health.Value)

if ed.Amnt.Value > 1 then
ed.Amnt.Value = ed.Amnt.Value - 1
else
targ:remove()
end
end
end
end

onMouseMove(mouse)
end)
end

function onDeselected()
frame.Parent = tool

if example ~= nil then
example.Parent = nil
end
end

tool.Selected:connect(onSelected)
tool.Deselected:connect(onDeselected)
Report Abuse
johny220 is not online. johny220
Joined: 30 Oct 2011
Total Posts: 4584
09 Nov 2014 10:37 AM
bumpy boomp
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