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
 

Scripts breaking in play mode?

Previous Thread :: Next Thread 
DudeofSparta is not online. DudeofSparta
Joined: 14 Nov 2010
Total Posts: 38
05 Sep 2012 12:01 AM
I've run into multiple incidents lately when the things I've put together worked perfectly in edit/build/test mode, but not in play mode. I've had a forage GUI and now a shield and sword tool that have both broken ONLY in play mode. What's with this .-.?
Report Abuse
UFAIL2 is not online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
05 Sep 2012 07:13 AM
Are they LocalScripts?
Report Abuse
DudeofSparta is not online. DudeofSparta
Joined: 14 Nov 2010
Total Posts: 38
06 Sep 2012 12:33 AM
No, they aren't. At least I don't think so.
Report Abuse
DudeofSparta is not online. DudeofSparta
Joined: 14 Nov 2010
Total Posts: 38
06 Sep 2012 03:55 PM
Bump
Report Abuse
lNightmarel is not online. lNightmarel
Joined: 02 Sep 2012
Total Posts: 54
06 Sep 2012 04:47 PM
Crap happens to me too. Only way I can fix them is if I find another way to do the same thing.
Report Abuse
DudeofSparta is not online. DudeofSparta
Joined: 14 Nov 2010
Total Posts: 38
06 Sep 2012 11:25 PM
Pretty stupid... I don't think there's any other way to have a sword and shield in one hand too :/
Report Abuse
DudeofSparta is not online. DudeofSparta
Joined: 14 Nov 2010
Total Posts: 38
07 Sep 2012 03:51 PM
Bump :<
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
07 Sep 2012 03:52 PM
Maybe um....



Oh idk....



Post the Script?
Report Abuse
DudeofSparta is not online. DudeofSparta
Joined: 14 Nov 2010
Total Posts: 38
07 Sep 2012 05:47 PM
wait(3)

local TOOL = script.Parent

local SCREEN_GUI = TOOL.ScreenGui
local FRAME = SCREEN_GUI.Frame

--BUTTONS
local CLEAR_BUTTON = FRAME.ClearButton
local ITEM_BUTTON = FRAME.ItemButton
local PROCESS_BUTTON = FRAME.ProcessButton
local TOOL_BUTTON = FRAME.ToolButton

--LABELS
local ALERT_LABEL = FRAME.AlertLabel
local LIST_LABEL = FRAME.ListLabel
local TARGET_LABEL = FRAME.TargetLabel

--OTHER
local RANGE = 15
local SERVICES = game.Workspace.Services

--MAIN STUFF
local SELECTED = {}
local CHOOSING = false

--INGREDIENT TABLES
local TOOL_TABLE = {

{
{"Stone", "Stone"},
"Sword"
},

{
{"Stone", "Stone", "Stone", ""},
"Tower"
},

{
{"Med Rock", "Med Rock", "Med Wood", ""},
"Well"
},

{
{"Wall", "Wall", "Large Foliage", ""},
{"Large Hut Center", "Large Hut Edge", "Large Hut Door", "Large Hut Corner"}
},

{
{"Med Rock", "Med Rock", "Med Wood", "Med Wood", ""},
{"M. Home Center", "M. Home Corner", "M. Home Edge", "M. Home Door", "M. Home Stairs", "Mine"}
},

{
{"Med Rock", "Large Wood", "Large Wood", ""},
"Medieval Granary"
},

{
{"Small Rock", "Small Rock", ""},
"Flint"
},

{
{"Hull", ""},
"Raft"
},

{
{"Small Wood", "Rope", ""},
"Crude Bucket"
},

{
{"Wall", "Wall", "Med Rock", ""},
"Crude Granary"
},

{
{"Small Handle", "Copper", "Copper", ""},
{"Copper Axe", "Copper Pickaxe"}
},

{
{"Small Handle", "Iron", "Iron", ""},
{"Iron Axe", "Iron Pickaxe"}
}

} --TOOL TABLE END

local ITEM_TABLE = {

{
{"Stone", "Stone"},
"Sword"
},

{
{"Med Wood", "Med Wood", ""},
{"Wall", "Hull"}
},

{
{"Large Wood", ""},
{"Wall", "Hull"}
},

{
{"Hemp Stalk", "Hemp Stalk", ""},
"Fresh Hemp"
},

{
{"Hemp", ""},
"Rope"
},

{
{"Dough", ""},
"Bread Dough"
}

} --ITEM TABLE END

local PROCESS_TABLE = {

{
{"Fresh Hemp", ""},
"Began drying...",
function()
processTimedNameChange(SELECTED[1], "Drying Hemp", "Dark green", 30, "Hemp", "Brown")
end
},

{
{"Small Foliage", ""},
"Began composting...",
function()
processTimedCompost(SELECTED[1], "Rotting Leaves", "Small Compost", 30)
end
},

{
{"Med Foliage", ""},
"Began composting...",
function()
processTimedCompost(SELECTED[1], "Rotting Leaves", "Med Compost", 30)
end
},

{
{"Large Foliage", ""},
"Began composting...",
function()
processTimedCompost(SELECTED[1], "Rotting Leaves", "Fertile Compost", 30)
end
},

{
{"Berry", "Small Compost", ""},
"Planted berry...",
function()
processTimedFarming(SELECTED[1], SELECTED[2], 30)
end
},

{
{"Wheat", "Med Compost", ""},
"Planted wheat...",
function()
processTimedFarming(SELECTED[1], SELECTED[2], 50)
end
},

{
{"Hemp Stalk", "Med Compost", ""},
"Planted hemp...",
function()
processTimedFarming(SELECTED[1], SELECTED[2], 40)
end
},

{
{"Apple", "Fertile Compost", ""},
"Planted apple...",
function()
processTimedFarming(SELECTED[1], SELECTED[2], 60)
end
}

} --PROCESS TABLE END

--PROCESSING FUNCTIONS

function processTimedNameChange(part, nameA, colorA, time, nameB, colorB)
local partVal = createValue("Object", part.Name, part)

local nameAVal = createValue("String", "NameA", nameA)
local nameBVal = createValue("String", "NameB", nameB)
local colorAVal = createValue("BrickColor", "ColorA", getBC(colorA))
local colorBVal = createValue("BrickColor", "ColorB", getBC(colorB))
local timeVal = createValue("Number", "Time", time)

nameAVal.Parent = partVal
nameBVal.Parent = partVal
colorAVal.Parent = partVal
colorBVal.Parent = partVal
timeVal.Parent = partVal

partVal.Parent = SERVICES.TimedNameChange
end

function processTimedCompost(part, rotName, finName, time)
local partVal = createValue("Object", part.Name, part)

local rotNameVal = createValue("String", "RotName", rotName)
local nameVal = createValue("String", "FinName", finName)
local timeVal = createValue("Number", "Time", time)

rotNameVal.Parent = partVal
nameVal.Parent = partVal
timeVal.Parent = partVal

partVal.Parent = SERVICES.TimedCompost
end

function processTimedFarming(part, compost, time)
local partVal = createValue("Object", part.Name, part)

local compostVal = createValue("Object", "Compost", compost)
local timeVal = createValue("Number", "Time", time)

compostVal.Parent = partVal
timeVal.Parent = partVal

partVal.Parent = SERVICES.TimedFarming
end

function createValue(type, name, value)
local newVal = Instance.new(type.."Value")
newVal.Name = name
newVal.Value = value

return newVal
end

function getBC(string)
return BrickColor.new(string)
end

--MAIN FUNCTIONS
function updateList()
local string = ""

for index, child in pairs(SELECTED) do
if index ~= 1 then
string = string..", "
end

string = string..child.Name
end

LIST_LABEL.Text = string
end

function getIngName(index)
local part = SELECTED[index]

if part == nil then
return ""
else
return part.Name
end
end

function runIngredients(tab, process)
if process == nil then
process = false
end

local required = tab[1]
local made = tab[2]
local func = tab[3]

if #SELECTED < 1 then
return nil
end

for index, child in pairs(required) do
if getIngName(index) ~= child then
return nil
end
end

if process then
return made, func
else
return made
end
end

function alert(text)
ALERT_LABEL.Text = ""
wait(0.1)
ALERT_LABEL.Text = text
end

function getPC()
local player = TOOL.Parent.Parent
local char = player.Character

return player, char
end

function lockCheck(part)
return not part.Locked
end

function distanceCheck(part)
local player, char = getPC()
local head = char.Head
local dist = (head.Position - part.Position).magnitude

return (dist < RANGE)
end

function haveCheck(part)
for index, child in pairs(SELECTED) do
if child == part then
return true
end
end

return false
end

function canUse(part)
if part == nil then
return false
end

local bool = false

bool = (bool or lockCheck(part))
bool = (bool and distanceCheck(part))

return bool
end

function clearList()
SELECTED = {}

updateList()
end

function deleteList()
for index, child in pairs(SELECTED) do
child:remove()
end

clearList()
end

function creationChoice(tab)
CHOOSING = true

local chosen = nil

local x = 0
local y = 0

for index, child in pairs(tab) do
local newButton = Instance.new("TextButton")
newButton.Name = "ChoiceButton"
newButton.Size = UDim2.new(0, 100, 0, 25)
newButton.Position = UDim2.new(0, (400 + x), 1, (-301 + y))
newButton.Text = child

newButton.MouseButton1Down:connect(function()
chosen = child
end)

newButton.Parent = SCREEN_GUI

y = y + 25

if y > 100 then
y = 0
x = x + 100
end
end

while chosen == nil do
wait()
end

stopCreationChoice()

return chosen
end

function stopCreationChoice()
local buttons = SCREEN_GUI:GetChildren()

for index, child in pairs(buttons) do
if child.Name == "ChoiceButton" then
child:remove()
end
end

CHOOSING = false
end

--BUTTON FUNCTIONS
function clearSelected()
if CHOOSING then return end

clearList()

alert("Ingredients cleared")
end

function createTool()
if CHOOSING then return end

local made = nil

for index, child in pairs(TOOL_TABLE) do
made = runIngredients(child)

if made ~= nil then
break
end
end

if type(made) == "table" then
made = creationChoice(made)
end

if made == nil then
alert("Nothing created")
clearList()
else
alert(made.." created!")

giveTool(made)

deleteList()
end
end

function giveTool(name)
local player, char = getPC()
local backpack = player.Backpack
local tools = game.Lighting.Tools

local made = tools:findFirstChild(name)

if made ~= nil then
made:clone().Parent = backpack
else
alert("Davidii messed up")
end
end

function createItem()
if CHOOSING then return end

local made = nil

for index, child in pairs(ITEM_TABLE) do
made = runIngredients(child)

if made ~= nil then
break
end
end

if type(made) == "table" then
made = creationChoice(made)
end

if made == nil then
alert("Nothing created")
clearList()
else
alert(made.." created!")

giveItem(made)

deleteList()
end
end

function processItem()
if CHOOSING then return end

local processMessage = nil
local processFunction = nil

for index, child in pairs(PROCESS_TABLE) do
processMessage, processFunction = runIngredients(child, true)

if processMessage ~= nil then
break
end
end

if processMessage == nil and processFunction == nil then
alert("Nothing happened")

clearList()
else
alert(processMessage)

processFunction()

clearList()
end
end

function giveItem(name)
local player, char = getPC()
local pack = player.Pack
local items = game.Lighting.Items

local real = items:findFirstChild(name)

if real ~= nil then
local new = real:clone()
new.Parent = pack
else
alert("Davidii messed up")
end
end

--MOUSE FUNCTIONS
function onMouseMove(mouse)
if CHOOSING then return end

local targ = mouse.Target

TARGET_LABEL.Text = ""

if canUse(targ) then
TARGET_LABEL.Text = targ.Name
end
end

function onButton1Down(mouse)
if CHOOSING then return end

local targ = mouse.Target

if canUse(targ) then
if not haveCheck(targ) then
selectTarget(targ)
else
alert("You already have that!")
end
end
end

function selectTarget(part)
alert(part.Name.." selected")

table.insert(SELECTED, part)

updateList()
end

--SELECTION FUNCTIONS
function onSelected(mouse)
local player, char = getPC()
local pg = player.PlayerGui

SCREEN_GUI.Parent = pg

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

mouse.Button1Down:connect(function()
onButton1Down(mouse)
end)
end

function onDeselected(mouse)
SCREEN_GUI.Parent = TOOL

stopCreationChoice()
end

--CONNECTIONS
TOOL.Selected:connect(onSelected)
TOOL.Deselected:connect(onDeselected)

CLEAR_BUTTON.MouseButton1Down:connect(clearSelected)
ITEM_BUTTON.MouseButton1Down:connect(createItem)
TOOL_BUTTON.MouseButton1Down:connect(createTool)
PROCESS_BUTTON.MouseButton1Down:connect(processItem)
Report Abuse
DudeofSparta is not online. DudeofSparta
Joined: 14 Nov 2010
Total Posts: 38
07 Sep 2012 05:48 PM
Taken from the craft tool from survival 404. For some reason, it gives me the tool, but no scripts inside it. This only happens in play mode.
Report Abuse
AdvorsusDuo is not online. AdvorsusDuo
Joined: 17 May 2012
Total Posts: 5265
07 Sep 2012 05:50 PM
Okay, that's quite a wordwall of unnecesarry code.

Why don't you just tell us where it errors, and write that portion of code instead of the entire thing?
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