|
| 01 Mar 2015 12:58 PM |
I made a script for a hopperbin that destroys your package and gives you a new one from a folder in ServerStorage. It is all ran from a LocalScript and works well in Studio Mode, but will do nothing in Game/Play mode. How can I make it work in Play mode? Here is the script:
local plr = game.Players.LocalPlayer local char = plr.Character local mouse = plr:GetMouse() local bin = script.Parent bin.Selected:connect(function() bin.EquippedValue.Value = true for _,v in pairs(char:GetChildren()) do if v:IsA("CharacterMesh") then v:Destroy() end end for _,k in pairs (game.ServerStorage.CharacterMeshFolder:GetChildren()) do local vclone = k:Clone() vclone.Parent = char end end)
Please help soon! Thanks! |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 01 Mar 2015 01:25 PM |
Is it in a LocalScript?
It has to be in a LocalScript. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 01:25 PM |
| Yes, it is in a LocalScript |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 01:26 PM |
sorry i didn't read ignore me
You can't access ServerStorage with LocalScripts
Use ReplicatedStorage instead. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 01:27 PM |
That still does not work :/ I have no Idea why
Also, nice username. I am a Christian as well :P |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 01:32 PM |
You need to move the CharacterMeshFolder into ReplicatedStorage. Then use this script:
local plr = game.Players.LocalPlayer local char = plr.Character local mouse = plr:GetMouse() local bin = script.Parent bin.Selected:connect(function() bin.EquippedValue.Value = true for _,v in pairs(char:GetChildren()) do if v:IsA("CharacterMesh") then v:Destroy() end end for _,k in pairs (game.ReplicatedStorage.CharacterMeshFolder:GetChildren()) do local vclone = k:Clone() vclone.Parent = char end end)
|
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 01:35 PM |
Hm, it still does not work! Strange, everything was done correctly.
This is why I hate Lua sometimes -__- |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 01 Mar 2015 02:07 PM |
I edited the script to where when F is pressed, it gives the package. Here is the script:
mouse.KeyDown:connect(function(Key) if bin.EquippedValue.Value == true then if Key == "f" then local pgui = plr.PlayerGui:FindFirstChild("MageActivationGui") if pgui then pgui:Destroy() end bin.CanAttack.Value = true for _,v in pairs(char:GetChildren()) do if v:IsA("CharacterMesh") then v:Destroy() end end for _,k in pairs (game.ReplicatedStorage.CharacterMeshFolder:GetChildren()) do local vclone = k:Clone() vclone.Parent = char end end elseif bin.EquippedValue.Value == false then if key == "f" then print("No") end end end)
Other Edits ~ Changed the CharacterMeshFolder from a Folder to a Model
The Script still doesn't work! How can I fix this? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
| 01 Mar 2015 03:54 PM |
print(bump[5]) > nil
Under these situations, it's very hard to help people. So, here's the way you help yourself.
The process of debugging involves understanding what the monstrosity you've made even does. It's hard to tell for humans what goes on in computers, and this is why debugging is even necessary.
The absolute best way to debug is to use a debugger, which is a tool in good IDEs. I'm not sure about Roblox's, and I think it's hard to use for somebody who is already having issues.
The second best is to print things. The output is always accessible, and it's great! Use it!
When something important happens, print its value in the output, and a helpful message like "10th line" or "second function"
By doing this, you identify what the code is doing. To fix your code, compare what actually happens to what you want to happen. Then you can inspect the specific area where something is wrong and hopefully fix it! |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 04:13 PM |
| I understand this, but the output is not accessible in-game. I still really do not understand this. Everything was done correctly, why doesn't it work in Play mode? |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 04:15 PM |
| I kinda contradicted what I just said, I meant I understand the debugging aspect, but I do not understand why the whole thing will not work when it is set up correctly |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 04:23 PM |
| any other ideas on how to make this work in-game? I cannot seem to figure it out at all :/ |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Mar 2015 04:41 PM |
'I understand this, but the output is not accessible in-game. I still really do not understand this. Everything was done correctly, why doesn't it work in Play mode?'
If you are the place owner, hit F9 in-game to open the output. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 04:42 PM |
'I do not understand why the whole thing will not work when it is set up correctly'
I think it's obvious at this point that it isn't set up correctly, and that's why things don't work. |
|
|
| Report Abuse |
|
|