Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ServerStorage and StreamingEnabled issue: grabbing a tool from ServerStorage?

Asked by 6 years ago
Edited 6 years ago

Hi there!

I am in the middle of converting my game to StreamingEnabled. It appears that mobile has an issue with rendering something from ServerStorage that I'm trying to get. I changed my script from FindFirstChild to WaitForChild, with no avail.

The reason I know it's because of StreamingEnabled and potentially a "rendering" issue is because my script works fine in a blank baseplate with nothing there except for stuff in ServerStorage and streamingenabled turned on. In my super packed game, however, it does not work.

What is a reliable way of getting this to work? Would ReplicatedStorage be more reliable? Perhaps ReplicatedFirst, as this would cause these objects to render first into the workspace? Is there something I can change within my script? (I tried both ReplicatedStorage and ReplicatedFirst, neither of these work)

local ServerStorage = game:GetService("ServerStorage")

game.ReplicatedStorage.keys.animal.OnServerEvent:Connect(function(plrWhoFiredEvent)
local guy = plrWhoFiredEvent

guy.TeamColor = BrickColor.new("1031")  

        game.ServerStorage.powers:WaitForChild("AnimalConnection")
        local AnimalConnection = game.ServerStorage.powers.AnimalConnection:clone()
        AnimalConnection.Parent = guy.Backpack

I am also using MouseButton1Down in a GUI for this function. I know that not all functions are reliable for StreamingEnabled, I'm trying to get the hang of it. Maybe this is the problem?

Thanks!

0
Assuming that you have a localscript that fires an event to a serverscript (and the script you have is the server script). You can put that script inside ServerScriptService and place the so called "powers" (the model or folder that stores the tool) in ServerScriptService. Now what you can do is script.Parent.powers:WaitForChild("AnimalConnection"). So you can just access an easier path Hakurem 30 — 6y
0
ohhh neat thank you Hakurem I like the way you think! Never thought of putting models in serverscriptservice. callmehbob 54 — 6y

2 answers

Log in to vote
1
Answered by
Hakurem 30
6 years ago

I might not be able to answer you question but i think WaitForChild does receive nil after a set ammount of time. Try using

repeat wait(.3) until game.ServerStorage.powers:FindFirstChild("AnimalConnection")

if you want you can put in a print to see if it loops infinately or it will stop until you find the item.

repeat wait(.3) print('still waiting for the tool') until game.ServerStorage.powers:FindFirstChild("AnimalConnection")

print('tool has been found finally')

local AnimalConnection = game.ServerStorage.powers:FindFirstChild("AnimalConnection"):Clone()

0
thank you so much! I will try this out! callmehbob 54 — 6y
0
although it never found it, it was still worth a try. i'll continue to try looking for alternatives. thanks! callmehbob 54 — 6y
0
Can you post the link to the game. I think I have a similar game where I have streaming enabled on and im using remoteevents to get a tool to the backpack when a player clicks a button in the gui. I am also using Button1Down and it seems to work fine on the laptop Hakurem 30 — 6y
0
Nope, it yields infinitely until the item is found. hiimgoodpack 2009 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Replicated first is what gets replicated FIRST to the client. This would be useful for custom loading GUIS. ServerStorage's contents only get replicated to the server, so clients cannot see it. Replicated Storage's contents is replicated to all clients AND the server.

Lets say what all would be used for. ServerStorage would be useful to keep someone's cash or stuff. ReplicatedStorage would be for all your remote events and stuff. ReplicatedFirst would be for loading screens and stuff.

Hope this helps!

Answer this question