Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This script doesn't work in servers/studio test severs, anyway to fix this?

the script below for a loadout doesn't work in servers/studio test severs, it usually works in studio

local Weapon = ""
local Storage = game.ServerStorage
Storage:WaitForChild("Odachi")
Storage:WaitForChild("Katana")

function Odachi()
	Weapon = "Odachi"
end
function Katana()
	Weapon = "Katana"
end
function Deploy()
	if Weapon ~= "" then
		local Clone = Storage[Weapon]:Clone()
		Clone.Parent = script.Parent.Parent.Parent.Parent.Backpack
		game.Players.LocalPlayer.PlayerScripts:WaitForChild("CameraScript"):Destroy()
		game.ServerStorage:WaitForChild("CameraScript"):Clone().Parent = game.Players.LocalPlayer.PlayerScripts
		game.Players.LocalPlayer.PlayerScripts.CameraScript.Disabled = false
		script.Parent.Parent:Destroy()
	end
	return
end
script.Parent.Odachi.MouseButton1Click:connect(Odachi)
script.Parent.Katana.MouseButton1Click:connect(Katana)
script.Parent.Deploy.MouseButton1Click:connect(Deploy)

1 comment

1 answer

✓ Accepted answer

Your problem is that it is a local script. You can't necessarily access game.ServerStorage with a local script. The reason it works in studio is because in studio, when you click the play button, everything is ran locally. So ServerStorage does work on the client, but in an actual server it doesnt.

A simple fix would be to use ReplicatedStorage instead of ServerStorage.

Hope I helped!

1 comment

0

thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.