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: I'm confused.

Previous Thread :: Next Thread 
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 09:12 AM
local tool = script.Parent --AxeForInventory--
local player = tool.Parent.Parent.Parent
local debounce = true

function Collect(mouse)

if mouse.Target ~= nil then
if mouse.Target.Parent.Name == "Tree" then
local thetree = mouse.Target.Parent
if (mouse.Target.Position - player.Character.Torso.Position).magnitude <= 15 then
if thetree.Hide.Value == 0 then
if player.PlayerGui.ScreenGui.Inv:findFirstChild("InventorySlotA") ~= nil then
if debounce == true then

local origwalkspeed = player.Character.Humanoid.WalkSpeed

-- And finally the actual script starts!

debounce = false

player.Character.Humanoid.WalkSpeed = 0

local bg = Instance.new("BillboardGui")
bg.Parent = player.PlayerGui
bg.Adornee = player.Character.Head
bg.Size = UDim2.new(4, 0, 4, 0)
bg.StudsOffset = Vector3.new(0, 5, 0)
local il = Instance.new("ImageLabel")
il.Parent = bg
il.Image = "http://www.roblox.com/asset/?id=62221219"
il.Size = UDim2.new(1, 0, 1, 0)
il.BackgroundTransparency = 1



wait(thetree.Time.Value)

bg:remove()

player.Character.Humanoid.WalkSpeed = origwalkspeed





local theItem = thetree.NameOfItemGiven.Value
local theItemsGui = game.Lighting.ItemLog:findFirstChild(theItem).Item:clone()
theItemsGui.Parent = player.PlayerGui.ScreenGui.Inv

thetree.Hide.Value = 1


local thetext = Instance.new("TextBox")
thetext.Parent = player.PlayerGui.ScreenGui
thetext.FontSize = Enum.FontSize.Size18
thetext.TextColor3 = Color3.new(1, 1, .5)
thetext.Position = UDim2.new(0.5, 0, 0.3, 0)
thetext.Text = "+ 1 " ..theItem.. "!"

wait(1.75)

thetext:remove()


debounce = true



end
else if player.PlayerGui.ScreenGui.Inv:findFirstChild("InventorySlotA") == nil then

local thetext = Instance.new("TextBox")
thetext.Parent = player.PlayerGui.ScreenGui
thetext.FontSize = Enum.FontSize.Size18
thetext.TextColor3 = Color3.new(1, 0, 0)
thetext.Position = UDim2.new(0.5, 0, 0.3, 0)
thetext.Text = "No Space in Inventory!"

wait(1.75)

thetext:remove()
end

end
end
end
end
end
end

script.Parent.Parent.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function() Collect(mouse) end)
end)


_________________________________________________

This script inside the Handle of the tool works flawlessly in Solo mode, but online it doesn't even start.

And I haven't the slightest idea why. Nothing shows up in Output.

Are there differences between how tools function in Solo and online?

Did I forget to localize something?
Report Abuse
ImpalerOfSouls is not online. ImpalerOfSouls
Joined: 17 Jan 2010
Total Posts: 2165
24 Sep 2011 09:13 AM
I thought tools were broken? probably not.

Anyway, it is in a localscript right?
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 09:16 AM
Local script? :o

It's inside the Handle of the Tool that is in starterpack and is given to each player once they spawn.
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 09:19 AM
I think I found the problem. I'm not tagging the Player correctly.
Let me see if fixing this does the job..
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 09:28 AM
Still doesn't work D:
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 09:36 AM
Help? :(
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 09:46 AM
... :'(
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
24 Sep 2011 09:57 AM
Convert it to a LocalScript. I've had this problem a million times, making it a LocalScript usually fixes it.


-Like an __AWESOME__ boss
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 10:03 AM
How do I make it a local script? :o
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
24 Sep 2011 10:08 AM
Change the player variable to game.Players.LocalPlayer, and copy all the code and paste it into a LocalScript? :/


-Like an __AWESOME__ boss
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 10:09 AM
I understoof that first part :D But I still don't know what a localscript is... D:

(I'm gonna look in objects to see if it's... an object)
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
24 Sep 2011 10:12 AM
It is. A LocalScript is like a script, but it only runs on the client. This means that it must be either a descendant of the player, or a descendant of the character.


-Like an __AWESOME__ boss
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 10:14 AM
Oh I see what you meant XD

I didn't know LocalScripts existed.

I'm still trying to find solutions to the issue now.
Report Abuse
AntiBoomz0r is online. AntiBoomz0r
Joined: 02 Oct 2009
Total Posts: 1345
24 Sep 2011 10:22 AM
Btw, dont use "Textbox" to show messages. Change it to "TextLabel".
Textboxes are boxes which text you can modify and write to by clicking on them. TextLabels are what you need in this ;)
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 01:01 PM
Thank you for the hint :D

You have no idea how much I appreciatte it
Report Abuse
Aurarus is not online. Aurarus
Joined: 22 Dec 2008
Total Posts: 4761
24 Sep 2011 01:15 PM
Still doesn't work. :(

Could someone try reformatting it?

This is what I've done so far:

local tool = script.Parent --AxeForInventory--
local theplayer = game.Players.LocalPlayer
local player = script.Parent.Parent.Parent
local debounce = true

function Collect(mouse)

if mouse.Target ~= nil then
if mouse.Target.Parent.Name == "Tree" then
local thetree = mouse.Target.Parent
if (mouse.Target.Position - tool.Position).magnitude <= 15 then
if thetree.Hide.Value == 0 then
if theplayer.PlayerGui.ScreenGui.Inv:findFirstChild("InventorySlotA") ~= nil then
if debounce == true then

local origwalkspeed = player.Humanoid.WalkSpeed

-- And finally the actual script starts!

debounce = false

player.Humanoid.WalkSpeed = 0

local bg = Instance.new("BillboardGui")
bg.Parent = theplayer.PlayerGui
bg.Adornee = player.Head
bg.Size = UDim2.new(4, 0, 4, 0)
bg.StudsOffset = Vector3.new(0, 5, 0)
local il = Instance.new("ImageLabel")
il.Parent = bg
il.Image = "http://www.roblox.com/asset/?id=62221219"
il.Size = UDim2.new(1, 0, 1, 0)
il.BackgroundTransparency = 1



wait(thetree.Time.Value)

bg:remove()

player.Humanoid.WalkSpeed = origwalkspeed





local theItem = thetree.NameOfItemGiven.Value
local theItemsGui = game.Lighting.ItemLog:findFirstChild(theItem).Item:clone()
theItemsGui.Parent = theplayer.PlayerGui.ScreenGui.Inv

thetree.Hide.Value = 1


local thetext = Instance.new("TextLabel")
thetext.Parent = theplayer.PlayerGui.ScreenGui
thetext.FontSize = Enum.FontSize.Size18
thetext.TextColor3 = Color3.new(1, 1, .5)
thetext.Position = UDim2.new(0.5, 0, 0.3, 0)
thetext.Text = "+ 1 " ..theItem.. "!"

wait(1.75)

thetext:remove()


debounce = true



end
else if theplayer.PlayerGui.ScreenGui.Inv:findFirstChild("InventorySlotA") == nil then

local thetext = Instance.new("TextLabel")
thetext.Parent = theplayer.PlayerGui.ScreenGui
thetext.FontSize = Enum.FontSize.Size18
thetext.TextColor3 = Color3.new(1, 0, 0)
thetext.Position = UDim2.new(0.5, 0, 0.3, 0)
thetext.Text = "No Space in Inventory!"

wait(1.75)

thetext:remove()
end

end
end
end
end
end
end

script.Parent.Parent.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function() Collect(mouse) end)
end)


_______________

And yes it's a localscript, and no nothing in the output.
Report Abuse
AntiBoomz0r is online. AntiBoomz0r
Joined: 02 Oct 2009
Total Posts: 1345
24 Sep 2011 01:32 PM
Problem is that your "player" is your "Backpack".
Also, there is "else if" when it could be "elseif"

Working version ahead:


local tool = script.Parent --AxeForInventory--
local theplayer = game.Players.LocalPlayer
local player = nil -- Moving this.
local debounce = true

function Collect(mouse)

if mouse.Target ~= nil then
if mouse.Target.Parent.Name == "Tree" then
local thetree = mouse.Target.Parent
if (mouse.Target.Position - tool.Position).magnitude <= 15 then
if thetree.Hide.Value == 0 then
if theplayer.PlayerGui.ScreenGui.Inv:findFirstChild("InventorySlotA") ~= nil then
if debounce == true then

local origwalkspeed = player.Humanoid.WalkSpeed

-- And finally the actual script starts!

debounce = false

player.Humanoid.WalkSpeed = 0

local bg = Instance.new("BillboardGui")
bg.Parent = theplayer.PlayerGui
bg.Adornee = player.Head
bg.Size = UDim2.new(4, 0, 4, 0)
bg.StudsOffset = Vector3.new(0, 5, 0)
local il = Instance.new("ImageLabel")
il.Parent = bg
il.Image = "http://www.roblox.com/asset/?id=62221219"
il.Size = UDim2.new(1, 0, 1, 0)
il.BackgroundTransparency = 1



wait(thetree.Time.Value)

bg:remove()

player.Humanoid.WalkSpeed = origwalkspeed





local theItem = thetree.NameOfItemGiven.Value
local theItemsGui = game.Lighting.ItemLog:findFirstChild(theItem).Item:clone()
theItemsGui.Parent = theplayer.PlayerGui.ScreenGui.Inv

thetree.Hide.Value = 1


local thetext = Instance.new("TextLabel")
thetext.Parent = theplayer.PlayerGui.ScreenGui
thetext.FontSize = Enum.FontSize.Size18
thetext.TextColor3 = Color3.new(1, 1, .5)
thetext.Position = UDim2.new(0.5, 0, 0.3, 0)
thetext.Text = "+ 1 " ..theItem.. "!"

wait(1.75)

thetext:remove()


debounce = true



end
elseif theplayer.PlayerGui.ScreenGui.Inv:findFirstChild("InventorySlotA") == nil then -- Made this into a "elseif" instead of "else if" and removed a end to make it work

local thetext = Instance.new("TextLabel")
thetext.Parent = theplayer.PlayerGui.ScreenGui
thetext.FontSize = Enum.FontSize.Size18
thetext.TextColor3 = Color3.new(1, 0, 0)
thetext.Position = UDim2.new(0.5, 0, 0.3, 0)
thetext.Text = "No Space in Inventory!"

wait(1.75)

thetext:remove()
end
end
end
end
end
end

script.Parent.Parent.Equipped:connect(function(mouse)
player = script.Parent.Parent.Parent -- Moved to here, since the "player" you have here, is actually the character. What the script did before, was setting the Backpack as "player"
mouse.Button1Down:connect(function() Collect(mouse) end)
end)
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