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
|
  |
| Joined: 30 Oct 2011 |
| Total Posts: 4584 |
|
|
| 09 Nov 2014 09:35 AM |
| Ctrl + F "Probably" is where the note is |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 30 Oct 2011 |
| Total Posts: 4584 |
|
| |
|